From e85cf00096c19182e0670ca473aa710b5b59bb4a Mon Sep 17 00:00:00 2001 From: 206530219 <236845922@qq.com> Date: Sat, 19 Jun 2021 11:56:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=82=A8=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E5=A4=A7=E9=83=A8=E5=88=86=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game_functions.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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)