Commit 44a50b71 by BellCodeEditor

save project

parent 74788ce8
Showing with 19 additions and 31 deletions
...@@ -21,6 +21,8 @@ index = 0 ...@@ -21,6 +21,8 @@ index = 0
y = 400 y = 400
jumpState = "running" jumpState = "running"
t = 30 t = 30
bg _x = 0
road_x = 0
obstacle = random.choice([bush,stone,cacti]) obstacle = random.choice([bush,stone,cacti])
rect = obstacle.get_rect() rect = obstacle.get_rect()
rect.x = 1000 rect.x = 1000
...@@ -32,7 +34,7 @@ while True: ...@@ -32,7 +34,7 @@ while True:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if jumpState == "runing": if jumpState == "running":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
...@@ -47,49 +49,35 @@ while True: ...@@ -47,49 +49,35 @@ while True:
y += t y += t
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "running"
t = 30 t = 30
wukong = hero[index] wukong = hero[index]
if jumpState == "runing": if jumpState == "running":
index += 1 index += 1
if index >= 5: if index >= 5:
index = 0 index = 0
bg_x -= 1
if bg_x <= -1000:
bg_x = 0
screen.blit(background,bg_x,0)
road_x -= 8
if road_x <= -1000
road_x = 0
screen.bilt(road,road_x,500)
screen.blit(wukong,(150,y))
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wukong, (150, y))
# 刷新画面
if rect.x <= 0 - rect.width:
if rect.x <= 0 - rect.width:
obstacle = random.choice([bush,stone,cacti]) obstacle = random.choice([bush,stone,cacti])
rect = obstacle.get_rect() rect = obstacle.get_rect()
rect.x = 1000 rect.x = 1000
rect.y = 500 - rect.height rect.y = 500 - rect.height
rect.x -= 8 rect.x -= 8
screen.blit(obstacle,(rect.x,rect.y)) screen.blit(obstacle,(rect.x,rect.y))
pygame.display.update()
FPS.tick(30)
pygame.display.update()
FPS.tick(30)
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