Commit af12837c by BellCodeEditor

save project

parent be1393c8
Showing with 12 additions and 10 deletions
...@@ -13,8 +13,9 @@ class Block(pygame.sprite.Sprite): ...@@ -13,8 +13,9 @@ class Block(pygame.sprite.Sprite):
class Player(pygame.sprite.Sprite): class Player(pygame.sprite.Sprite):
def __init__(self,image): def __init__(self,image):
super().__init__() super().__init__()
self.image = image
self.rect = self.image.get_rect() self.rect = self.image.get_rect()
self,rect.x = 150 self.rect.x = 150
self.rect.y = 400 self.rect.y = 400
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((1000, 600)) screen = pygame.display.set_mode((1000, 600))
...@@ -56,7 +57,7 @@ while True: ...@@ -56,7 +57,7 @@ while True:
# 悟空造型 # 悟空造型
wukong = hero[index] wukong = Player(hero[index])
if jumpState == "runing": # 跑步状态下 if jumpState == "runing": # 跑步状态下
index += 1 index += 1
if index >= 5: if index >= 5:
...@@ -96,7 +97,7 @@ while True: ...@@ -96,7 +97,7 @@ while True:
screen.blit(road, (lu_x, 500)) # 路 screen.blit(road, (lu_x, 500)) # 路
screen.blit(wukong.image, (150, y)) # 悟空 screen.blit(wukong.image, (150, y)) # 悟空
if aa.rect.x <= 0-aa.rect.width: # 障碍物消失 # 障碍物消失
# 创建障碍物对象 # 创建障碍物对象
time +=1 time +=1
if time >= 60: if time >= 60:
...@@ -109,13 +110,13 @@ while True: ...@@ -109,13 +110,13 @@ while True:
aa.rect.x -= 8 aa.rect.x -= 8
screen.blit(aa.image, (aa.rect.x, aa.rect.y)) screen.blit(aa.image, (aa.rect.x, aa.rect.y))
if sprite.rect.x <= 0-sprite.rect.width: if sprite.rect.x <= 0-sprite.rect.width:
sprite.kill() sprite.kill()
if pygame.sprite.collide_rect(wukong,sprite): if pygame.sprite.collide_rect(wukong,sprite):
gameover = pygame.image.load('gameovre.png') gameover = pygame.image.load('gameovre.png')
screen.blit(gameover,(400,200)) screen.blit(gameover,(400,200))
gamestate = False gamestate = False
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
\ No newline at end of file
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