Commit db637887 by BellCodeEditor

save project

parent ed4eaf60
Showing with 20 additions and 11 deletions
......@@ -26,28 +26,30 @@ y=400
z=random.choice([stone,cacti,apple])
rect=stone.get_rect()
z_x=1000
road_x=0
bg_x=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type==locals.KEYDOWN:
if event.key==locals.K_SPACE and y==400:
if event.key==locals.K_SPACE and wukong=='running':
wukong='up'
if wukong=='up':
if t>=0:
y-=t
if t>0:
y-=t
t-=2
else:
wukong='down'
if wukong=='down':
if t<30:
if t<=30:
y+=t
t+=2
else:
wukong='running'
t=30
y=400
#y=400
if wukong=='running':
wukong_1=hero[a]
......@@ -55,15 +57,22 @@ while True:
if a>=5:
a=0
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(background, (bg_x, 0))
screen.blit(road, (road_x, 500))
screen.blit(wukong_1, (150, y))
screen.blit(z, (z_x, 500-rect.height))
z_x-=5
if z_x<0-rect.width:
z_x-=8
road_x-=8
bg_x-=1
if z_x <= 0-rect.width:
z=random.choice([stone,cacti,apple])
rect=stone.get_rect()
z_x=1000
if road_x<-1000:
road_x=0
if bg_x<-1000:
bg_x=0
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
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