Commit a92f11a6 by BellCodeEditor

save project

parent 080ee70a
Showing with 20 additions and 8 deletions
...@@ -18,6 +18,8 @@ hero = [pygame.image.load('hero1.png'), ...@@ -18,6 +18,8 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
lux = 0
jinx = 0
index = 0 index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
...@@ -50,17 +52,14 @@ while True: ...@@ -50,17 +52,14 @@ while True:
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =30
# 悟空造型 # 悟空造型
wukong = hero[index] wukong = hero[index]
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
index = 0 index = 0
# 将背景图画上去
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: # 障碍物消失
# 创建障碍物对象 # 创建障碍物对象
...@@ -69,7 +68,20 @@ while True: ...@@ -69,7 +68,20 @@ while True:
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))
jinx -= 2
if jinx <= -1000:
jinx = 0
screen.blit(background,(jinx,0))
lux -= 8
if lux <= -1000:
lux = 0
screen.blit(road,(lux,500))
screen.blit(obstacle, (rect.x, rect.y))
# 将背景图画上去
screen.blit(wukong, (150, y)) # 悟空
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(45)
\ No newline at end of file \ 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