Commit 95da995f by BellCodeEditor

save project

parent a06d5732
Showing with 13 additions and 2 deletions
...@@ -11,6 +11,16 @@ class Block(pygame.sprite.Sprite): ...@@ -11,6 +11,16 @@ class Block(pygame.sprite.Sprite):
self.rect.y=500-self.rect.height self.rect.y=500-self.rect.height
pygame.init() # 初始化 pygame.init() # 初始化
# 创建一个窗口 # 创建一个窗口
class Player(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("悟空酷跑")
...@@ -58,7 +68,8 @@ while True: ...@@ -58,7 +68,8 @@ while True:
t =30 t =30
# 悟空造型 # 悟空造型
wukong = hero[index]
wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
...@@ -72,7 +83,7 @@ while True: ...@@ -72,7 +83,7 @@ while True:
if lu_x <-1000: if lu_x <-1000:
lu_x=0 lu_x=0
screen.blit(road, (lu_x, 500)) # 路 screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong.image, (150, y)) # 悟空
time+=1 time+=1
if time >=60: if time >=60:
time=0 time=0
......
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