From 82e22c4a7a20078c89ec847efdd5a74abeecc577 Mon Sep 17 00:00:00 2001 From: 206530219 <236845922@qq.com> Date: Thu, 17 Jun 2021 20:19:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=82=A8=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E5=A4=A7=E9=83=A8=E5=88=86=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game_functions.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/game_functions.py b/game_functions.py index 960a858..132ef14 100644 --- a/game_functions.py +++ b/game_functions.py @@ -45,4 +45,17 @@ def check_keyup_events(event, ship): elif event.key == pygame.K_UP: ship.moving_up = False elif event.key == pygame.K_DOWN: - ship.moving_down = False \ No newline at end of file + ship.moving_down = False +def check_events(ai_settings, screen, stats, sb, play_button, ship, aliens, bullets): + """响应按键和鼠标事件""" + for event in pygame.event.get(): + if event.type == pygame.QUIT: + sys.exit() + elif event.type == pygame.KEYDOWN: + check_keydown_events(event, ai_settings, screen, ship, bullets) + elif event.type == pygame.KEYUP: + check_keyup_events(event, ship) + elif event.type == pygame.MOUSEBUTTONDOWN: + 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)