Пример #1
0
    def _fire_alien(self):
        # for alien in self.aliens.sprites():
        alien = random.choice(self.aliens.sprites())

        new_alien_bullet = AlienBullet(self)
        self.alien_bullets.add(new_alien_bullet)

        new_alien_bullet.rect.midbottom = alien.rect.center
        new_alien_bullet.y = float(alien.rect.y)
        self.settings.last_alien_shot = time.clock()
Пример #2
0
def create_alien_bullet(ai_settings, screen, alien_bullets):
	"""
	Create alien bullets which start position's based on the random 
	position of the fleet of aliens 
	"""
	while (len(alien_bullets) < ai_settings.alien_bullets_allowed):		
		alien_bullet = AlienBullet(ai_settings, screen)
		chosen_alien = choice(alien_list)
		alien_bullet.rect.x = chosen_alien.rect.x
		alien_bullet.y = float(chosen_alien.rect.y)
		alien_bullet.rect.y = alien_bullet.y
		alien_bullets.add(alien_bullet)