Beispiel #1
0
def creat_ship_bullet_team():
    bullet_team = []

    for name in ship_bullet_data:
        bullet = Ship_Bullet()
        bullet.range = ship_bullet_data[name]['range']
        bullet_team.append(bullet)

    return bullet_team
Beispiel #2
0
def enter():
    global soldier, space_world, soldier_bullet_team, tower, ship_bullet_team, alien_team

    space_world = Space_World()
    soldier = Soldier()
    tower = Tower()
    soldier_bullet_team = [Soldier_Bullet() for i in range(10)]
    ship_bullet_team = [Ship_Bullet() for i in range(30)]
    alien_team = [Alien() for i in range(30)]

    soldier.get_space(space_world)
    tower.get_space(space_world)

    for alien in alien_team:
        alien.get_tower(tower)
Beispiel #3
0
    def on_key_press(self, key, modifiers):
        """
        Monitors keyboard press events.
        """
        #  move left and right
        if key == arcade.key.RIGHT:
           self.ship.move_right = True
        if key == arcade.key.LEFT:
            self.ship.move_left = True
        
        #  fire bullets
        if key == arcade.key.SPACE:
            if len(self.ship_bullet_list) < 3:
                bullet = Ship_Bullet(self.ai_settings, self.ship)
                self.ship_bullet_list.append(bullet)

        #  quit the game
        if key == arcade.key.ESCAPE:
            print("Writing the score to the disk...")
            self.gamestats.update_highscore()
            self.gamestats.save_score()
            arcade.close_window()
Beispiel #4
0
def fire_bullet(ai_settings, screen, ship, ship_bullets):
    """Fire a bullet if limit not reached yet"""
    # Create a new bullet and add it to the bullets group
    if len(ship_bullets) < ai_settings.ship_bullets_allowed:
        new_bullet = Ship_Bullet(ai_settings, screen, ship)
        ship_bullets.add(new_bullet)