存储项目的大部分函数

This commit is contained in:
206530219 2021-06-19 11:56:17 +08:00
parent 9757093adf
commit e85cf00096
1 changed files with 25 additions and 1 deletions

View File

@ -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
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)