def check_aliens_bottom(ai_settings, stats, screen, ship, bullets, aliens): """检查是否有外星人到达了屏幕底端""" screen_rect = screen.get_rect() for alien in aliens.sprites(): if alien.rect.bottom >= screen_rect.bottom: ship_hit(ai_settings, stats, screen, ship, bullets, aliens) break
def check_aliens_bottom(ai_settings, stats, screen, ship, aliens, bullets): screen_rect = screen.get_rect() for alien in aliens.sprites(): if alien.rect.bottom >= screen_rect.bottom: ship_hit(ai_settings, stats, screen, ship, aliens, bullets) break
def change_fleet_direction(ai_settings, aliens): for alien in aliens.sprites(): alien.rect.y += ai_settings.fleet_drop_speed ai_settings.fleet_drop_direction *= -1
def check_fleet_edges(ai_settings, aliens): for alien in aliens.sprites(): if alien.check_edges(): change_fleet_direction(ai_settings, aliens) break
def change_fleet_direction(ai_settings, aliens): """将外星人向下移动,并改变运动方向""" for alien in aliens.sprites(): alien.rect.y += ai_settings.fleet_drop_speed ai_settings.fleet_direction *= -1