def create_alien(ai_settings, screen, aliens, alien_number, row_number): """Create an alien, and place it in the row.""" alien = Alien1341(ai_settings, screen) alien_width = alien.rect.width alien.x = alien_width + 2 * alien_width * alien_number alien.rect.x = alien.x alien.rect.y = alien.rect.height + 2 * alien.rect.height * row_number aliens.add(alien)
def create_fleet(ai_settings, screen, ship, aliens): """Create a full fleet of aliens.""" # Create an alien, and find number of aliens in a row. alien = Alien1341(ai_settings, screen) number_aliens_x = get_number_aliens_x(ai_settings, alien.rect.width) number_rows = get_number_rows(ai_settings, ship.rect.height, alien.rect.height) # Create the fleet of aliens. for row_number in range(number_rows): for alien_number in range(number_aliens_x): create_alien(ai_settings, screen, aliens, alien_number, row_number)