Commit 06a0a456 by BellCodeEditor

save project

parent 22c09262
Showing with 13 additions and 4 deletions
...@@ -18,7 +18,8 @@ hero = [pygame.image.load('hero1.png'), ...@@ -18,7 +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')]
bg=0
road_x=0
index = 0 index = 0
a='running' a='running'
y=400 y=400
...@@ -27,6 +28,7 @@ b=random.choice([apple,stone,cacti]) ...@@ -27,6 +28,7 @@ b=random.choice([apple,stone,cacti])
rect=b.get_rect() rect=b.get_rect()
rect.x=1000 rect.x=1000
rect.y=500-rect.height rect.y=500-rect.height
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:
...@@ -49,15 +51,22 @@ while True: ...@@ -49,15 +51,22 @@ while True:
a='runing' a='runing'
t=30 t=30
wk=hero[index] wk=hero[index]
if a=='runing': if a=='runing':
index+=1 index+=1
if index==5: if index==5:
index=0 index=0
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) bg-=2
screen.blit(road, (0, 500)) if bg<=-1000:
bg=0
screen.blit(background,(bg,0))
road_x-=8
if road_x<=-1000:
road_x=0
screen.blit(road(road_x,500))
screen.blit(background, (bg, 0))
screen.blit(road, (road_x, 500))
screen.blit(wk, (150, y)) screen.blit(wk, (150, y))
if rect.x<=0-rect.width: if rect.x<=0-rect.width:
b=random.choice([apple,stone,cacti]) b=random.choice([apple,stone,cacti])
......
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