From dc6669ca9090d170d58504eb71e17cf7014ccf1f Mon Sep 17 00:00:00 2001 From: 206530211 <1515969111@qq.com> Date: Sat, 19 Jun 2021 12:24:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20'game=5Ffunctions.py'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game_functions.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/game_functions.py b/game_functions.py index 5d66b80..9890bef 100644 --- a/game_functions.py +++ b/game_functions.py @@ -8,4 +8,16 @@ from alien import Alien def check_keydown_events(event, ai_settings, screen, ship, bullets): - """响应按键""" \ No newline at end of file + """响应按键""" + if event.key == pygame.K_RIGHT: + ship.moving_right = True + elif event.key == pygame.K_LEFT: + ship.moving_left = True + elif event.key == pygame.K_UP: + ship.moving_up = True + elif event.key == pygame.K_DOWN: + ship.moving_down = True + elif event.key == pygame.K_SPACE: + fire_bullet(ai_settings, screen, ship, bullets) + elif event.key == pygame.K_q: + sys.exit() \ No newline at end of file