Commit 436db26f by BellCodeEditor

auto save

parent d8a5ad68
Showing with 18 additions and 27 deletions
...@@ -11,15 +11,7 @@ class Block(pygame.sprite.Sprite) : ...@@ -11,15 +11,7 @@ class Block(pygame.sprite.Sprite) :
self.rect = self.image.get_rect() self.rect = self.image.get_rect()
self.rect.x = 1000 self.rect.x = 1000
self.rect.y = 500 - self.rect.height self.rect.y = 500 - self.rect.height
class Player(pygame.sprite.Sprite) :
def __init__(self,image):
super().__init__()
self.image = image
#self.image = random.choice([image1,image2,image3])
#self.rect = self.image.get_rect()
self = self.image.get_rect()
self.rect.x = 150
self.rect.y = 400
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
...@@ -35,12 +27,11 @@ hero = [pygame.image.load('hero1.png'), ...@@ -35,12 +27,11 @@ hero = [pygame.image.load('hero1.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')]
score_audio= p
index = 0 index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
gamestate = True
time = 0 time = 0
#obstacle = Block([bush, stone, cacti]) #obstacle = Block([bush, stone, cacti])
block_list = pygame.sprite.Group() block_list = pygame.sprite.Group()
...@@ -52,26 +43,26 @@ while True: ...@@ -52,26 +43,26 @@ while True:
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
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]) wukong = hero[index]
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
index = 0 index = 0
if gamestate == True: if g
if jumpState == "up": # 起跳状态 if jumpState == "up": # 起跳状态
if t > 0: if t > 0:
y -= t y -= t
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
t += 2 t += 2
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =30
# 悟空造型 # 悟空造型
......
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