Commit ac01d48a by BellCodeEditor

save project

parent 86333fe7
Showing with 25 additions and 9 deletions
...@@ -18,6 +18,10 @@ index = 0 ...@@ -18,6 +18,10 @@ index = 0
y = 400 y = 400
zt = "pb" zt = "pb"
t = 30 t = 30
zaw=random.choice([stone,cacti,apple])
rect=zaw.get_rect()
rect.x=1000
rect.y=500-rect.height
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -29,24 +33,35 @@ while True: ...@@ -29,24 +33,35 @@ while True:
if event.key==locals.K_SPACE: if event.key==locals.K_SPACE:
zt="up" zt="up"
if zt=="up": if zt=="up":
if y>150: if t>0:
y-=5 y-=t
t-=2
else: else:
zt="down" zt="down"
if zt=="down": if zt=="down":
if y<400: if t<30:
y+=5 y+=t
t+=2
else: else:
zt="pb" zt="pb"
t=30
wuplay=hero[index] y=400
index+=1 if zt == "pb":
if index==5: wuplay=hero[index]
index=0 index+=1
if index==5:
index=0
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(wuplay, (150, y)) screen.blit(wuplay, (150, y))
# 刷新画面 # 刷新画面
if rect.x<0:
zaw=random.choice([stone,cacti,apple])
rect=zaw.get_rect()
rect.x=1000
rect.y=500-rect.height
rect.x-=10
screen.blit(zaw,(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