diff --git a/game_functions.py b/game_functions.py index 4dc62b8..9f3fc6f 100644 --- a/game_functions.py +++ b/game_functions.py @@ -134,4 +134,28 @@ def check_bullet_collisions(ai_settings, screen, stats, sb, ship, aliens, bossal if stats.level != stats.bosslevel - 1: create_fleet(ai_settings, screen, ship, aliens) else: - pass \ No newline at end of file + pass + # 增加:只有在BOSS关才启用 + elif stats.level == stats.bosslevel: + + # 子弹击中BOSS外星人,BOSS外星人失去一定血量 + for bullet in bullets: + if pygame.Rect.colliderect(bullet.rect, bossalien.rect): + bossalien.health -= 100 + bullets.remove(bullet) + + # 生命值为0时删除该BOSS + if bossalien.health <= 0: + # 提高等级,加分 + stats.level += 1 + sb.prep_level() + stats.score += ai_settings.bossalien_points + sb.prep_score() + check_high_score(stats, sb) + + create_fleet(ai_settings, screen, ship, aliens) + + # BOSS发射子弹和船碰撞 + + if pygame.Rect.colliderect(bossbullet.rect, ship.rect): + ship_hit(ai_settings, screen, stats, sb, ship, aliens, bullets, bossalien, bossbullet)