Commit b62c88cd by BellCodeEditor

save project

parent 8ed3ebba
Showing with 21 additions and 8 deletions
print('hello world')
\ No newline at end of file
...@@ -19,6 +19,11 @@ pygame.image.load('hero5.png')] ...@@ -19,6 +19,11 @@ pygame.image.load('hero5.png')]
index = 0 index = 0
y=400 y=400
zzz='runing' zzz='runing'
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():
...@@ -26,25 +31,31 @@ while True: ...@@ -26,25 +31,31 @@ while True:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE and zzz=='runing':
zzz='up' zzz='up'
if zzz=='up': if zzz=='up':
if y>150: if t>=0:
y-=30 y-=t
t-=2
else: else:
zzz='down' zzz='down'
if zzz=='down': if zzz=='down':
if y<400: if t<=30:
y+=20 y+=t
t+=2
else: else:
zzz='runing' zzz='runing'
t = 30
if rect=
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
screen.blit(hero[index], (150, y)) screen.blit(hero[index], (150, y))
index+=1 if zzz== 'runing':
if index>4: index+=1
index=0 if index>4:
index=0
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
......
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