Beispiel #1
0
 def get_angle_laser(self, x, y, direction):
     return [
         ProjectileLaser(x, y, direction * self.speed, self.angle,
                         direction, self.dmg),
         ProjectileLaser(x, y, direction * self.speed,
                         (90 - self.angle) + 90, direction, self.dmg)
     ]
Beispiel #2
0
 def get_angle_laser(self, x, y, is_player):
     return [
         ProjectileLaser(x, y, self.speed, self.dir_vec, is_player,
                         self.dmg),
         ProjectileLaser(x, y, self.speed,
                         [self.dir_vec[0], -self.dir_vec[1]], is_player,
                         self.dmg)
     ]
Beispiel #3
0
    def get_rail_gun(self, x, y, is_player):
        closest_enemy = None
        closest_dist = 123123123
        if is_player:
            for enemy in globals.enemies:
                dist = util.distance((self.x, self.y), (enemy.x, enemy.y))
                if dist < closest_dist:
                    closest_dist = dist
                    closest_enemy = enemy
        else:
            closest_enemy = globals.player_ship

        if closest_enemy is None:
            return []

        target_vec = [0, 0]
        target_vec[0] = closest_enemy.x - self.x
        target_vec[1] = closest_enemy.y - self.y
        length = util.get_vector_length(target_vec)
        target_vec[0] /= length
        target_vec[1] /= length

        # black magic
        if not is_player:
            target_vec[0] = -1 * target_vec[0]

        proj = ProjectileLaser(x, y, self.speed, target_vec, is_player,
                               self.dmg)
        proj.scale = 4.0
        return [proj]
Beispiel #4
0
    def get_rail_gun(self, x, y, direction):
        closest_enemy = None
        closest_dist = 123123123
        if not self._owner.is_enemy:
            for enemy in globals.enemies:
                dist = util.distance((self.x, self.y), (enemy.x, enemy.y))
                if dist < closest_dist:
                    closest_dist = dist
                    closest_enemy = enemy
        else:
            closest_enemy = globals.player_ship

        print("Closest Enemy for Railgun: {}/{}".format(
            closest_enemy.x, closest_enemy.y))

        #angle = math.degrees(math.atan2(closest_enemy.y - y, closest_enemy.x - x))
        angle = math.degrees(
            math.atan((closest_enemy.y - y) / (closest_enemy.x - x)))
        #angle = angle if angle >= 0 else angle + 360

        proj = ProjectileLaser(x, y, self.speed, angle, direction, self.dmg)
        proj.scale = 4.0
        return [proj]
Beispiel #5
0
 def get_heavy_laser(self, x, y, direction):
     proj = ProjectileLaser(x, y, direction * self.speed, self.angle,
                            direction, self.dmg)
     proj.scale = 2.0
     return [proj]
Beispiel #6
0
 def get_simple_laser_projectile(self, x, y, direction):
     return [
         ProjectileLaser(x, y, direction * self.speed, self.angle,
                         direction, self.dmg)
     ]
Beispiel #7
0
 def get_heavy_laser(self, x, y, is_player):
     proj = ProjectileLaser(x, y, self.speed, self.dir_vec, is_player,
                            self.dmg)
     proj.scale = 2.0
     return [proj]
Beispiel #8
0
 def get_simple_laser_projectile(self, x, y, is_player):
     projectile = ProjectileLaser(x, y, self.speed, self.dir_vec, is_player,
                                  self.dmg)
     array = []
     array.append(projectile)
     return array