Commit 32011cc7 by BellCodeEditor

auto save

parent f8a413d8
Showing with 4 additions and 12 deletions
...@@ -5,19 +5,12 @@ import random ...@@ -5,19 +5,12 @@ import random
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
class Block(pygame.sprite.Sprite): class Block(pygame.sprite.Sprite):
def __init__(self,image,image2,image3): def __init__(self,image1,image2,image3):
super().__init__() super().__init__()
self.image=random.choice([image1,image2,image3]) self.image=random.choice([image1,image2,image3])
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 Block(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__()
self.image=image
self.rect=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时钟,控制游戏速度(帧数)
pygame.display.set_caption("悟空酷跑") pygame.display.set_caption("悟空酷跑")
...@@ -38,7 +31,7 @@ jumpState = "runing" ...@@ -38,7 +31,7 @@ jumpState = "runing"
t = 30 t = 30
road_x=0 road_x=0
background_x=0 background_x=0
# obstacle = Block(bush, stone, cacti) obstacle = Block(bush, stone, cacti)
# rect = obstacle.get_rect() # rect = obstacle.get_rect()
# rect.x = 1000 # rect.x = 1000
# rect.y = 500 - rect.height # rect.y = 500 - rect.height
...@@ -66,10 +59,9 @@ while True: ...@@ -66,10 +59,9 @@ while True:
else: else:
jumpState = "runing" jumpState = "runing"
t =30 t =30
# 悟空造型 # 悟空造型
wukong = Player(hero[index]) wukong = hero[index]
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
...@@ -83,7 +75,7 @@ while True: ...@@ -83,7 +75,7 @@ while True:
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)) # 路
screen.blit(wukong.image, (150, y)) # 悟空 screen.blit(wukong, (150, y)) # 悟空
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失 if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
# 创建障碍物对象 # 创建障碍物对象
......
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