diff --git a/__pycache__/alien.cpython-39.pyc b/__pycache__/alien.cpython-39.pyc deleted file mode 100644 index 8699bd9..0000000 Binary files a/__pycache__/alien.cpython-39.pyc and /dev/null differ diff --git a/__pycache__/bullet.cpython-39.pyc b/__pycache__/bullet.cpython-39.pyc deleted file mode 100644 index 2f88d55..0000000 Binary files a/__pycache__/bullet.cpython-39.pyc and /dev/null differ diff --git a/__pycache__/button.cpython-39.pyc b/__pycache__/button.cpython-39.pyc deleted file mode 100644 index 88491c8..0000000 Binary files a/__pycache__/button.cpython-39.pyc and /dev/null differ diff --git a/__pycache__/game_functions.cpython-39.pyc b/__pycache__/game_functions.cpython-39.pyc deleted file mode 100644 index b14edcd..0000000 Binary files a/__pycache__/game_functions.cpython-39.pyc and /dev/null differ diff --git a/__pycache__/game_stats.cpython-39.pyc b/__pycache__/game_stats.cpython-39.pyc deleted file mode 100644 index 0820eef..0000000 Binary files a/__pycache__/game_stats.cpython-39.pyc and /dev/null differ diff --git a/__pycache__/music.cpython-39.pyc b/__pycache__/music.cpython-39.pyc deleted file mode 100644 index 7a8757c..0000000 Binary files a/__pycache__/music.cpython-39.pyc and /dev/null differ diff --git a/__pycache__/scoreboard.cpython-39.pyc b/__pycache__/scoreboard.cpython-39.pyc deleted file mode 100644 index 1a69723..0000000 Binary files a/__pycache__/scoreboard.cpython-39.pyc and /dev/null differ diff --git a/__pycache__/settings.cpython-39.pyc b/__pycache__/settings.cpython-39.pyc deleted file mode 100644 index a0ba557..0000000 Binary files a/__pycache__/settings.cpython-39.pyc and /dev/null differ diff --git a/__pycache__/ship.cpython-39.pyc b/__pycache__/ship.cpython-39.pyc deleted file mode 100644 index 790d45d..0000000 Binary files a/__pycache__/ship.cpython-39.pyc and /dev/null differ diff --git a/alien_invasion.py b/alien_invasion.py deleted file mode 100644 index d7b000e..0000000 --- a/alien_invasion.py +++ /dev/null @@ -1,75 +0,0 @@ - -# 系统自带的类或函数 -# import sys # 退出游戏----集中在game_functions.py中使用,故这注释掉 -import pygame # 含有开发游戏所需功能 -from pygame.sprite import Group # 存储所有有效子弹的类 - -# 自定义的类或函数 -from settings import Settings # 对《外星人入侵》游戏中所有设置的类,如屏幕宽高… -from ship import Ship # 创建飞船的类 -from button import Button # 创建按钮的类 -from game_stats import Game_Stats # 创建跟踪游戏统计信息的类 -from scoreboard import Scoreboard # 创建得分类 -from music import bg_music # 背景音乐 -import game_functions as gf # 所有的功能函 - - -def run_game(): - # 初始化游戏并创建一个屏幕对象 - pygame.init() - ai_settings = Settings() - screen = pygame.display.set_mode( - (ai_settings.screen_width, ai_settings.screen_height)) - pygame.display.set_caption("外星人入侵") - - # 初始化声音播放模块 - pygame.mixer.init() - - # 创建Play按钮 - play_button = Button(ai_settings, screen, "Play") - - # 创建一艘飞船 - ship = Ship(ai_settings, screen) - - # 创建一个用于存储子弹的编组 - bullets = Group() - - # 创建一个用于存储外星人的编组 - aliens = Group() - - # 创建存储游戏统计信息的实例 - game_stats = Game_Stats(ai_settings) - - # 创建记分牌 - scoreb = Scoreboard(ai_settings, screen, game_stats) - - # 创建外星人群 - gf.create_fleet(ai_settings, screen, ship, aliens) - - # 加载背景音乐 - bg_music() - - # 开始游戏的主循环 - while True: - - # 调用响应鼠标和键盘事件的函数 - gf.check_events(ai_settings, screen, game_stats, scoreb, play_button, ship, aliens, bullets) - - if game_stats.game_active: - - # 调用背景音乐 - gf.play_bg_music() - # 调用飞船水平持续移动的函数 - ship.update() - - # 调用关于子弹相关操作的函数 - gf.update_bullets(ai_settings, screen, game_stats, scoreb, ship, aliens, bullets) - - # 调用外星人向右移动的函数 - gf.update_aliens(ai_settings, game_stats, scoreb, screen, ship, aliens, bullets) - - # 调用更新屏幕上的图像并切换到新屏幕的函数 - gf.update_screen(ai_settings, screen, game_stats, scoreb, ship, aliens, bullets, play_button) - - -run_game() # 此时运行的话 会弹出一个pygame窗口 \ No newline at end of file