Commit 852b89f0 by BellCodeEditor

save project

parent 4fe2d97c
Showing with 15 additions and 2 deletions
...@@ -18,6 +18,11 @@ hero = [pygame.image.load('hero1.png'), ...@@ -18,6 +18,11 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
sj = random.choice([stone,cacti,apple])
rect = sj.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
index = 0 index = 0
y = 400 y = 400
state='runing' state='runing'
...@@ -28,7 +33,6 @@ while True: ...@@ -28,7 +33,6 @@ while True:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if state == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
state = "up" state = "up"
if state == "up": if state == "up":
...@@ -46,7 +50,6 @@ while True: ...@@ -46,7 +50,6 @@ while True:
t = 30 t = 30
wukong=hero[index] wukong=hero[index]
if state == "runing":
index+=1 index+=1
if index==5: if index==5:
index=0 index=0
...@@ -54,6 +57,15 @@ while True: ...@@ -54,6 +57,15 @@ 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))
if rect.x < 0 - rect.width:
sj = random.choice([stone,cacti,apple])
rect = sj.get_rect()
rect.x = 1000
rect.y = 500 - rect.height
rect.x -= 8
screen.blit(sj,(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