Commit 9723608f by BellCodeEditor

save project

parent 6d7272aa
Showing with 13 additions and 4 deletions
...@@ -18,6 +18,7 @@ hero = [pygame.image.load('hero1.png'), ...@@ -18,6 +18,7 @@ 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')]
a=0
index = 0 index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
...@@ -26,7 +27,7 @@ obstacle = random.choice([bush, stone, cacti]) ...@@ -26,7 +27,7 @@ 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
q=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:
...@@ -58,9 +59,15 @@ while True: ...@@ -58,9 +59,15 @@ while True:
if index >= 5: if index >= 5:
index = 0 index = 0
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) # 远处背景 screen.blit(background, (a, 0)) # 远处背景
screen.blit(road, (0, 500)) # 路 q-=8
screen.blit(wukong, (150, y)) # 悟空 if q<-1000:
q=0
a-=1
if a<-1000:
a=0
screen.blit(road,(q,500)) # 路
screen.blit(wukong,(150,y)) # 悟空
if rect.x <= 0-rect.width: # 障碍物消失 if rect.x <= 0-rect.width: # 障碍物消失
# 创建障碍物对象 # 创建障碍物对象
...@@ -71,5 +78,6 @@ while True: ...@@ -71,5 +78,6 @@ while True:
rect.x -= 8 rect.x -= 8
screen.blit(obstacle, (rect.x, rect.y)) screen.blit(obstacle, (rect.x, rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) 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