Commit f1de9412 by BellCodeEditor

save project

parent 80b7e96d
Showing with 12 additions and 9 deletions
...@@ -23,7 +23,7 @@ y = 400 ...@@ -23,7 +23,7 @@ y = 400
t=30 t=30
s=random.choice([stone,cacti,apple]) s=random.choice([stone,cacti,apple])
rect = s.get_rect() rect = s.get_rect()
rect.x=500 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():
...@@ -31,8 +31,9 @@ while True: ...@@ -31,8 +31,9 @@ while True:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type==locals.KEYDOWN: if event.type==locals.KEYDOWN:
if event.key==locals.K_SPACE and a=="running": if a=="running":
a="up" if event.key==locals.K_SPACE:
a="up"
if a=="up": if a=="up":
if t>0: if t>0:
y-=t y-=t
...@@ -46,13 +47,13 @@ while True: ...@@ -46,13 +47,13 @@ while True:
else: else:
a="running" a="running"
t=30 t=30
# if rect.x<0-rect.width: if rect.x<0-rect.width:
# s=random.choice([stone,cacti,apple]) s=random.choice([stone,cacti,apple])
# rect = s.get_rect() rect = s.get_rect()
# rect.x=1000 rect.x=1000
# rect.y=500-rect.height rect.y=500-rect.height
rect.x-=10 rect.x-=10
screen.blit(s, (rect.x, rect.y))
wukong = hero[x] wukong = hero[x]
if a=="running": if a=="running":
x+=1 x+=1
...@@ -62,6 +63,7 @@ while True: ...@@ -62,6 +63,7 @@ while True:
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(wukong, (150, y)) screen.blit(wukong, (150, y))
screen.blit(s, (rect.x, rect.y))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(25) FPS.tick(25)
\ 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