From d9a6e36284ce4acfa6c9116d0a85194fdf1009ad Mon Sep 17 00:00:00 2001 From: pl3g9npaj <18798213833@163.com> Date: Sun, 7 Nov 2021 08:45:07 +0800 Subject: [PATCH] ADD file via upload --- bazi_invasion.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 bazi_invasion.py diff --git a/bazi_invasion.py b/bazi_invasion.py new file mode 100644 index 0000000..94832d8 --- /dev/null +++ b/bazi_invasion.py @@ -0,0 +1,61 @@ +import pygame +from pygame.sprite import Group + +from settings import Settings +from game_stats import GameStats +from scoreboard import Scoreboard +from button import Button +from man import Man +import game_functions as gf + +def run_game(): + # 初始化 pygame, settings, and screen object. + pygame.init() + ai_settings = Settings() + screen = pygame.display.set_mode( + (ai_settings.screen_width, ai_settings.screen_height)) + pygame.display.set_caption("Alien Invasion") + + # 制作开始游戏按钮 + play_button = Button(ai_settings, screen, "Play") + + # 创建一个实例来存储游戏统计信息和记分板。 + stats = GameStats(ai_settings) + sb = Scoreboard(ai_settings, screen, stats) + + # 设置背景颜色 + bg_color = (230, 230, 230) + + # Make a ship, a group of bullets, and a group of aliens. + man = Man(ai_settings, screen) + bullets = Group() + bazis = Group() + + # 创造靶子队列 + gf.create_fleet(ai_settings, screen, man, bazis) + + # 开始游戏的主循环 + while True: + gf.check_events(ai_settings, screen, stats, sb, play_button, man, + bazis, bullets) + + if stats.game_active: + man.update() + gf.update_bullets(ai_settings, screen, stats, sb, man, bazis, + bullets) + gf.update_bazis(ai_settings, screen, stats, sb, man, bazis, + bullets) + + gf.update_screen(ai_settings, screen, stats, sb, man, bazis, + bullets, play_button) + + +if __name__ == "__main__": + try: + run_game() + except SystemExit: + pass + except: + # traceback.print_exc() + pygame.quit() + input()