Commit bcd14e3f by BellCodeEditor

save project

parent 4829a8ad
Showing with 27 additions and 3 deletions
...@@ -41,9 +41,8 @@ t = 30 ...@@ -41,9 +41,8 @@ t = 30
road_x = 0 road_x = 0
bg_x = 0 bg_x = 0
time = 0 time = 0
block_list = pygame.sprite.Group() gamestate = True
block_list =pygame.sprite.Group()
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -54,16 +53,24 @@ while True: ...@@ -54,16 +53,24 @@ while True:
if jumpState == "runing": if jumpState == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
wukong = Player(hero[index])
if jumpState == "runing":
index += 1
if index >= 5:
index = 0
if gamestate==True:
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
wukong.rect.y = y
t -= 2 t -= 2
else: else:
jumpState = "down" jumpState = "down"
if jumpState == "down": # 降落状态 if jumpState == "down": # 降落状态
if t <= 30: if t <= 30:
y += t y += t
wykong.rect.y = y
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "runing"
...@@ -75,6 +82,22 @@ while True: ...@@ -75,6 +82,22 @@ while True:
index += 1 index += 1
if index >= 5: if index >= 5:
index = 0 index = 0
if gamestate == True:
if jumpState == "up":
if t > 0:
y -= t
wukong.rect.y = y
t -=2
else:
jumpState = "down"
if jumpState == "down":
if t <= 30:
y += t
wukong.rect.y = y
t += 2
else:
jumpState = "runing"
t =30
bg_x -= 1 bg_x -= 1
if bg_x<-1000: if bg_x<-1000:
bg_x = 0 bg_x = 0
...@@ -100,6 +123,7 @@ while True: ...@@ -100,6 +123,7 @@ while True:
if pygame.sprite.collide_rect(wukong, sprite): if pygame.sprite.collide_rect(wukong, sprite):
gameover = pygame.image.load('gameover.png') gameover = pygame.image.load('gameover.png')
screen.blit(gameover, (400,200)) screen.blit(gameover, (400,200))
gamestate = False
# 刷新画面 # 刷新画面
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