Commit 99e07cef by BellCodeEditor

save project

parent e3af8d26
Showing with 19 additions and 2 deletions
......@@ -5,7 +5,7 @@ pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock()
pygame. # pygame时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑") # pygame时钟,控制游戏速度(帧数)
# 载入图片
background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
......@@ -20,6 +20,8 @@ hero = [pygame.image.load('hero1.png'),
index = 0
y=400
j="running"
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -29,12 +31,26 @@ while True:
index+=1
if index==5:
index=0
if event.type==locals.KEYDOWN:
if event.key==locals.K_SPACE:
j="up"
if j=="up":
if y>150:
y-=5
else:
j="down"
if j=="down":
if y<400:
y+=5
else:
j="running"
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wk, (150, 400))
screen.blit(wk, (150, y))
# 刷新画面
pygame.display.update()
FPS.tick(100)
\ 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