存储项目的大部分函数

This commit is contained in:
206530219 2021-06-19 12:33:10 +08:00
parent 6b3b05364a
commit 5429100c85
1 changed files with 10 additions and 0 deletions

View File

@ -302,3 +302,13 @@ def ship_hit(ai_settings, screen, stats, sb, ship, aliens, bullets, bossalien, b
pygame.mixer.init()
sound = pygame.mixer.Sound('sounds/gameover.wav')
sound.play()
def check_aliens_bottom(ai_settings, screen, stats, sb, ship, aliens, bullets):
"""检查是否有外星人到达了屏幕底端"""
screen_rect = screen.get_rect()
for alien in aliens.sprites():
if alien.rect.bottom >= screen_rect.bottom:
# 像飞船被撞到一样进行处理
ship_hit(ai_settings, screen, stats, sb, ship, aliens, bossalien, bullets)
break