Commit bcd14e3f by BellCodeEditor

save project

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