diff --git a/my_game.py b/my_game.py index 2dfed8d..0042b62 100644 --- a/my_game.py +++ b/my_game.py @@ -23,7 +23,7 @@ y = 400 t=30 s=random.choice([stone,cacti,apple]) rect = s.get_rect() -rect.x=500 +rect.x=1000 rect.y=500-rect.height while True: for event in pygame.event.get(): @@ -31,8 +31,9 @@ while True: # 接收到退出事件后退出程序 exit() if event.type==locals.KEYDOWN: - if event.key==locals.K_SPACE and a=="running": - a="up" + if a=="running": + if event.key==locals.K_SPACE: + a="up" if a=="up": if t>0: y-=t @@ -46,13 +47,13 @@ while True: else: a="running" t=30 - # if rect.x<0-rect.width: - # s=random.choice([stone,cacti,apple]) - # rect = s.get_rect() - # rect.x=1000 - # rect.y=500-rect.height + if rect.x<0-rect.width: + s=random.choice([stone,cacti,apple]) + rect = s.get_rect() + rect.x=1000 + rect.y=500-rect.height rect.x-=10 - screen.blit(s, (rect.x, rect.y)) + wukong = hero[x] if a=="running": x+=1 @@ -62,6 +63,7 @@ while True: screen.blit(background, (0, 0)) screen.blit(road, (0, 500)) screen.blit(wukong, (150, y)) + screen.blit(s, (rect.x, rect.y)) # 刷新画面 pygame.display.update() FPS.tick(25) \ No newline at end of file