From 8aa5ac8a0f85fb96861365f8f8a534fb84817909 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sun, 10 Jul 2022 18:51:51 +0800 Subject: [PATCH] auto save --- my_game.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/my_game.py b/my_game.py index e5979a0..5a96472 100644 --- a/my_game.py +++ b/my_game.py @@ -14,15 +14,21 @@ apple = pygame.image.load('bush.png') # 灌木丛 hero = [pygame.image.load('hero1.png'),pygame.image.load('hero2.png'),pygame.image.load('hero3.png'),pygame.image.load('hero4.png'),pygame.image.load('hero5.png')] index = 0 pygame.display.set_caption("悟空跑酷") +y=400 +j="run" while True: for event in pygame.event.get(): if event.type == locals.QUIT: # 接收到退出事件后退出程序 exit() - if index==len(hero)-1: - index=0 - index=index+1 + if event.key == locals.KEYDOWN: + if event.key == locals.K_SPACE: + + wukong=hero[index] + index=index+1 + if index>=5: + index=0 # 将背景图画上去 screen.blit(background, (0, 0)) -- libgit2 0.25.0