Commit a3674c92 by BellCodeEditor

save project

parent 60882b7c
Showing with 14 additions and 4 deletions
...@@ -15,6 +15,16 @@ class Block(pygame.sprite.Sprite): ...@@ -15,6 +15,16 @@ class Block(pygame.sprite.Sprite):
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,image1,image2,image3):
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("悟空酷跑")
...@@ -69,7 +79,7 @@ while True: ...@@ -69,7 +79,7 @@ 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:
...@@ -77,10 +87,10 @@ while True: ...@@ -77,10 +87,10 @@ while True:
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) # 远处背景 screen.blit(background, (0, 0)) # 远处背景
screen.blit(road, (0, 500)) # 路 screen.blit(road, (0, 500)) # 路
screen.blit(wukong, (150, y)) # 悟空 screen.blit(wukong.image, (150, y)) # 悟空
if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失 #if obstacle.rect.x <= 0-obstacle.rect.width: # 障碍物消失
obstacle = Block(bush,cacti,stone) obstacle = Block(bush,cacti,stone)
obstacle.rect.x -= 8 obstacle.rect.x -= 8
for prop in block_list: for prop in block_list:
......
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