Commit aa3cf22e by BellCodeEditor

save project

parent eba38b06
Showing with 19 additions and 4 deletions
import pygame
from pygame import locals
y = 400
pygame.init() # 初始化
jumpState = "running"
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -24,6 +25,20 @@ while True:
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_SPACE:
jumpState = "up"
if jumpState == "up":
if y > 150:
y -= 5
else:
jumpState = "down"
if jumpState == "down":
if y < 400:
y += 5
else:
jumpState == "running"
wukong = hero[index]
index += 1
if index >= 5:
......@@ -31,7 +46,7 @@ while True:
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wukong, (150, 400))
screen.blit(wukong, (150,y))
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
FPS.tick(15)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment