Commit 576951a8 by BellCodeEditor

save project

parent a20fbe30
Showing with 12 additions and 10 deletions
...@@ -43,8 +43,9 @@ hero = [pygame.image.load('hero1.png'), ...@@ -43,8 +43,9 @@ hero = [pygame.image.load('hero1.png'),
#basic_font = pygame.font.Font('STKAITI.TTF',32) #basic_font = pygame.font.Font('STKAITI.TTF',32)
index = 0 index = 0
y = 400 y = 400
score=0
jumpState = "runing" jumpState = "runing"
t = 30 t = 4
road_x = 0 road_x = 0
bg_x = 0 bg_x = 0
time = 0 time = 0
...@@ -62,7 +63,7 @@ while True: ...@@ -62,7 +63,7 @@ while True:
if jumpState == "runing": if jumpState == "runing":
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
speed=8+speed//3 speed=8+score//3
# 悟空造型 # 悟空造型
wukong = Player(hero[index]) wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
...@@ -75,17 +76,17 @@ while True: ...@@ -75,17 +76,17 @@ while True:
if t > 0: if t > 0:
y -= t y -= t
wukong.rect.y = y wukong.rect.y = y
t -= 2 t -= 0.01
else: else:
jumpState = "down" jumpState = "down"
if jumpState == "down": # 降落状态 if jumpState == "down": # 降落状态
if t <= 30: if t <= 4:
y += t y += t
wukong.rect.y = y wukong.rect.y = y
t += 2 t += 0.01
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =4
# 将背景图画上去 # 将背景图画上去
bg_x -= 1 bg_x -= 1
...@@ -93,7 +94,7 @@ while True: ...@@ -93,7 +94,7 @@ while True:
bg_x = 0 bg_x = 0
screen.blit(background, (bg_x, 0)) # 远景 screen.blit(background, (bg_x, 0)) # 远景
road_x -= 8 road_x -= speed
if road_x<=-1000: if road_x<=-1000:
road_x = 0 road_x = 0
screen.blit(road, (road_x, 500)) # 道路 screen.blit(road, (road_x, 500)) # 道路
...@@ -117,10 +118,11 @@ while True: ...@@ -117,10 +118,11 @@ while True:
screen.blit(gameover, (400, 200)) screen.blit(gameover, (400, 200))
gamestate = False gamestate = False
else: else:
score+=1 score+=10
#scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0)) #scoreSurf = basic_font.render("分数:"+str(score),True,(255,0,0))
#screen.blit(scoreSurf,(850,20)) #screen.blit(scoreSurf,(850,20))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ No newline at end of file print(score)
\ 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