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)
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)
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)
def add_bullet(self): bullet = Bullet(self.settings, self.screen, self.ship) bullet.add(self.bullets)