Commit aa677f57 by BellCodeEditor

save project

parent 6bb30439
Showing with 7 additions and 4 deletions
...@@ -19,7 +19,7 @@ hero = [pygame.image.load('hero1.png'), ...@@ -19,7 +19,7 @@ hero = [pygame.image.load('hero1.png'),
index = 0 index = 0
y = 400 y = 400
mode = 0 mode = 0
g = 20
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
...@@ -30,17 +30,20 @@ while True: ...@@ -30,17 +30,20 @@ while True:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
# 将背景图画上去 # 将背景图画上去
y += 10 * mode y += g * mode
g += mode
if y <= 150: if y <= 150:
mode = 1 mode = 1
if y >= 400: if y >= 400:
mode = 0 mode = 0
if mode == 0:
g = 20
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(road, (0, 500)) screen.blit(road, (0, 500))
if mode == 0:
i += 1 i += 1
screen.blit(hero[i % 5], (150, y)) screen.blit(hero[i % 5], (150, y))
pygame.display.set_caption('悟空酷跑') pygame.display.set_caption('悟空酷跑')
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(24) FPS.tick(24)
\ No newline at end of file
print(mode)
\ 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