存储项目的大部分函数

This commit is contained in:
206530219 2021-06-18 23:36:16 +08:00
parent 59428ed9e4
commit ddf6acbfc0
1 changed files with 29 additions and 0 deletions

View File

@ -59,3 +59,32 @@ def check_events(ai_settings, screen, stats, sb, play_button, ship, aliens, bull
mouse_x, mouse_y = pygame.mouse.get_pos()
check_play_button(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets, mouse_x, mouse_y)
def update_screen(ai_settings, screen, stats, sb, ship, aliens, bossalien, bullets, bossbullet, play_button):
screen.fill(ai_settings.bg_color)
ship.blitme()
# 在飞船和外星人后面重绘所有子弹
for bullet in bullets.sprites():
bullet.draw_bullet()
# 增加如果进入BOSS关则绘制BOSS外星人其他关卡绘制普通外星人
if stats.level == stats.bosslevel:
bossalien.blitme()
bossalien.draw_health_bar(screen)
bossbullet.draw_bullet()
bossalien_fire_bullet(ai_settings, screen, bossalien, bossbullet, ship)
check_bossbullet_bottom(ai_settings, screen, stats, sb, ship, aliens, bossalien, bullets, bossbullet)
else:
aliens.draw(screen)
# 显示得分
sb.show_score()
# 如果游戏处于非活动状态就绘制Play按钮
if not stats.game_active:
play_button.draw_button()
# 让最近绘制的屏幕可见
pygame.display.flip()