Commit 6007dcd3 by BellCodeEditor

save project

parent 080ee70a

12.4 KB | W: | H:

13 KB | W: | H:

hero1.png
hero1.png
hero1.png
hero1.png
  • 2-up
  • Swipe
  • Onion skin

10.9 KB | W: | H:

11.5 KB | W: | H:

hero2.png
hero2.png
hero2.png
hero2.png
  • 2-up
  • Swipe
  • Onion skin

11.3 KB | W: | H:

11.9 KB | W: | H:

hero3.png
hero3.png
hero3.png
hero3.png
  • 2-up
  • Swipe
  • Onion skin

11.5 KB | W: | H:

12.3 KB | W: | H:

hero4.png
hero4.png
hero4.png
hero4.png
  • 2-up
  • Swipe
  • Onion skin

11.9 KB | W: | H:

12.7 KB | W: | H:

hero5.png
hero5.png
hero5.png
hero5.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -19,14 +19,15 @@ hero = [pygame.image.load('hero1.png'), ...@@ -19,14 +19,15 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
index = 0 index = 0
y = 400 y = 420
jumpState = "runing" jumpState = "runing"
t = 30 t = 36
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
road_x=0
bg_x=0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -44,12 +45,12 @@ while True: ...@@ -44,12 +45,12 @@ while True:
else: else:
jumpState = "down" jumpState = "down"
if jumpState == "down": # 降落状态 if jumpState == "down": # 降落状态
if t <= 30: if t <= 36:
y += t y += t
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =36
# 悟空造型 # 悟空造型
wukong = hero[index] wukong = hero[index]
...@@ -58,16 +59,24 @@ while True: ...@@ -58,16 +59,24 @@ while True:
if index >= 5: if index >= 5:
index = 0 index = 0
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) # 远处背景 screen.blit(background, (bg_x, 0))
screen.blit(road, (0, 500)) # 路 bg_x-=1
if bg_x<=-1000:
bg_x=0 # 远处背景
screen.blit(road, (road_x, 500))
road_x-=8
if road_x<=-1000:
road_x=0 # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
if rect.x <= 0-rect.width: # 障碍物消失 if rect.x <= 0-rect.width: # 障碍物消失
# 创建障碍物对象 # 创建障碍物对象
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
obstacle = random.choice([bush,stone,cacti])
rect.x -= 8 rect.x -= 8
screen.blit(obstacle, (rect.x, rect.y)) screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面 # 刷新画面
......
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