"""
shotJ.py - red semi-homing
"""

import common
import shot
import explosionA

class ShotJ(shot.Shot):

    # rect = 2d pos -> width+height will be appended!
    def __init__(self,rect,level):
        rect  += [7,7]
        shot.Shot.__init__(self,1,rect)
        self.images  = common.images['ShotJ']
        self.speed_x = (common.player.rect[0]-self.rect[0])/100
        self.speed_y = (common.player.rect[1]-self.rect[1])/100
        if self.speed_x == 0: self.speed_x = 1
        if self.speed_y == 0: self.speed_y = 1
        self.level   = level
        self.damage  = 5+level*5

        common.shots_enemy.append(self)

    def move(self):        
        if self.rect[1] > common.resolution[1] or \
           self.rect[1] < -10:
            common.shots_enemy.remove(self)
            return
        self.rect[1] += self.speed_y
        if self.rect[0] > common.resolution[0] or \
           self.rect[0] < -10:
            common.shots_enemy.remove(self)
            return
        self.rect[0] += self.speed_x

    def explode(self):
        explosionA.ExplosionA([self.rect[0],self.rect[1]])
