Commit db637887 by BellCodeEditor

save project

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