From 45f8071066b4f3e54e8db30797c79b735c4dc9df Mon Sep 17 00:00:00 2001 From: Luo050129 <2802501399@qq.com> Date: Sun, 13 Jul 2025 20:05:40 +0800 Subject: [PATCH] Update main.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在主循环内添加ESC键检测,去掉了原来检测窗口是否关闭的代码段(因为有这段代码也没用)当用户按下ESC键时项目会关闭。 --- bin/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/main.py b/bin/main.py index 6623a0b..7965d7e 100644 --- a/bin/main.py +++ b/bin/main.py @@ -164,7 +164,10 @@ def main(): our_plane.move_left() if key_pressed[K_d] or key_pressed[K_RIGHT]: our_plane.move_right() - + if key_pressed[K_pressed] + pygame.quit() + sys.exit() + os._exit(0) # 绘制图像并输出到屏幕上面 pygame.display.flip()