示例#1
0
    def shoot(self):
        """Chooses a random bottom enemy to shoot
        the bullet is added to the self.bullets group
        """

        # pick a random living enemy, then make the bottom living enemy of that column shoot
        r = random.randint(0, len(self) - 1)
        ##print ("Random = ", r)
        ##print ("Enemies = ", len(self))
        col = Group.sprites(self)[r].col
        shooter = self.bottom_sprite(col)

        new_bullet = Bullet(window_size, bullet_filename, bullet_speed, shooter.rect.center, SOUTH)
        new_bullet.add(self.bullets)
示例#2
0
文件: enemy.py 项目: Helyosis/jam
 def shoot(self, x, y):
     theta = pi - atan2(y - self.hitbox.centery, x - self.hitbox.x)
     print(theta)
     bullet = Bullet(self.hitbox.x, self.hitbox.centery, theta, self.game)
     bullet.add(self.game.all_sprites, self.game.all_game_objects,
                self.game.characters)
示例#3
0
def shoot():
    """Creates a new friendly bullet at the player's location if too many don't exist already
    """
    if len(good_bullets) < max_player_bullets:
        new_bullet = Bullet(window_size, bullet_filename, bullet_speed, player.rect.center, NORTH)
        new_bullet.add(good_bullets)
示例#4
0
 def add_bullet(self):
     bullet = Bullet(self.settings, self.screen, self.ship)
     bullet.add(self.bullets)