Commit da3d6d1d by BellCodeEditor

save project

parent 4882ebc8
Showing with 6 additions and 5 deletions
...@@ -39,8 +39,8 @@ hero = [pygame.image.load('hero1.png'), ...@@ -39,8 +39,8 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero2.png'), pygame.image.load('hero2.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') ]
basic_font = pygame.font.Font(32) basic_font = pygame.font.Font(None,32)
index = 0 index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
...@@ -49,7 +49,7 @@ road_x = 0 ...@@ -49,7 +49,7 @@ road_x = 0
bg_x = 0 bg_x = 0
time = 0 time = 0
gamestate = True gamestate = True
score=0
block_list =pygame.sprite.Group() # 创建精灵组 block_list =pygame.sprite.Group() # 创建精灵组
while True: while True:
...@@ -74,14 +74,14 @@ while True: ...@@ -74,14 +74,14 @@ while True:
if t > 0: if t > 0:
y -= t y -= t
wukong.rect.y = y wukong.rect.y = y
t -= 2 t -= 1
else: else:
jumpState = "down" jumpState = "down"
if jumpState == "down": # 降落状态 if jumpState == "down": # 降落状态
if t <= 30: if t <= 30:
y += t y += t
wukong.rect.y = y wukong.rect.y = y
t += 2 t += 1
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =30
...@@ -110,6 +110,7 @@ while True: ...@@ -110,6 +110,7 @@ while True:
sprite.rect.x -= 8 sprite.rect.x -= 8
screen.blit(sprite.image, (sprite.rect.x, sprite.rect.y)) screen.blit(sprite.image, (sprite.rect.x, sprite.rect.y))
if sprite.rect.x <= 0-sprite.rect.width: if sprite.rect.x <= 0-sprite.rect.width:
score+=1
sprite.kill() sprite.kill()
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') # 游戏结束
......
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