Commit 54821328 by BellCodeEditor

save project

parent f8899f0f
Showing with 26 additions and 4 deletions
......@@ -29,6 +29,7 @@ t = 30
obstacle = Java(bush, stone, cacti)
road_x = 0
background_x = 0
ed = 8
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -38,6 +39,26 @@ while True:
if jumpState == "runing":
if event.key == locals.K_SPACE:
jumpState = "up"
if event.key == locals.K_1:
ed = 8
if event.key == locals.K_2:
ed = 10
if event.key == locals.K_3:
ed = 12
if event.key == locals.K_4:
ed = 14
if event.key == locals.K_5:
ed = 16
if event.key == locals.K_6:
ed = 18
if event.key == locals.K_7:
ed = 20
if event.key == locals.K_8:
ed = 22
if event.key == locals.K_9:
ed = 24
if event.key == locals.K_0:
ed = 0
if jumpState == "up": # 起跳状态
if t > 0:
y -= t
......@@ -52,13 +73,13 @@ while True:
jumpState = "runing"
t =30
wukong = hero[index]
if jumpState == "runing": # 跑步状态下
if jumpState == "runing":
index += 1
if index >= 5:
index = 0
background_x -= 8
background_x -= 3
screen.blit(background, (background_x, 0))
road_x -= 10
road_x -= ed
screen.blit(road, (road_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空
if road_x < -1000:
......@@ -67,7 +88,7 @@ while True:
background_x = 0
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
obstacle = Java(bush,stone,cacti)
obstacle.rect.x -= 10
obstacle.rect.x -= ed
screen.blit(obstacle.image, (obstacle.rect.x, obstacle.rect.y))
pygame.display.update()
FPS.tick(60)
\ 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