Commit 1d6eaee7 by BellCodeEditor

save project

parent 63255ade
Showing with 6 additions and 6 deletions
import pygame import pygame
from pygame import locals from pygame import locals
import random import random
speed = 8
pygame.init() # 初始化 pygame.init() # 初始化
score_music = pygame.mixer.Sound('score.wav') score_music = pygame.mixer.Sound('score.wav')
class Block(pygame.sprite.Sprite): # 障碍物精灵类 class Block(pygame.sprite.Sprite): # 障碍物精灵类
...@@ -59,8 +59,9 @@ while True: ...@@ -59,8 +59,9 @@ 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 =speed +score //3
print(speed)
wukong = Player(hero[index])# 悟空造型切换 wukong = Player(hero[index])# 悟空造型切换
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
...@@ -90,7 +91,7 @@ while True: ...@@ -90,7 +91,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)) # 道路
...@@ -100,8 +101,7 @@ while True: ...@@ -100,8 +101,7 @@ while True:
time += 1 time += 1
if time >= 60: # 每隔一秒创建障碍物精灵 if time >= 60: # 每隔一秒创建障碍物精灵
time = 0 time = 0
speed =speed +score //3
print(speed)
num = random.randint(0,50) num = random.randint(0,50)
if num > 10: if num > 10:
obstacle = Block(bush,cacti,stone) obstacle = Block(bush,cacti,stone)
......
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