Commit 675d904a by BellCodeEditor

save project

parent 6f9f7676
Showing with 8 additions and 8 deletions
...@@ -6,10 +6,10 @@ from pygame import locals ...@@ -6,10 +6,10 @@ from pygame import locals
pygame.init() # 初始化 pygame.init() # 初始化
class Block(pygame.sprite.Sprite): class Block(pygame.sprite.Sprite):
def _init_ (self,image1,image2,image3): def __init__ (self,image1,image2,image3):
surper()._init_() super().__init__()
self.image = random.choice([image1,image2,image3]) self.image = random.choice([image1,image2,image3])
self.rect = 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
...@@ -42,9 +42,9 @@ hero = [pygame.image.load('hero1.png'), ...@@ -42,9 +42,9 @@ hero = [pygame.image.load('hero1.png'),
zhang_ai = Block(stone,cacti,bush) zhang_ai = Block(stone,cacti,bush)
rect = zhang_ai.get_rect() #rect = zhang_ai.get_rect()
rect.x=1000 #rect.x=1000
rect.y = 500-rect.height #rect.y = 500-rect.height
index = 0 index = 0
...@@ -95,9 +95,9 @@ while True: ...@@ -95,9 +95,9 @@ while True:
#障碍:随机,移动 #障碍:随机,移动
if zhang_ai.rect.x <= 0-zhang_ai.rect.width: if zhang_ai.rect.x <= 0-zhang_ai.rect.width:
zhang_ai = Block([stone,cacti,bush]) zhang_ai = Block(stone,cacti,bush)
zhang_ai.rect.x -=8 zhang_ai.rect.x -=8
screen.blit(zhang_ai,(zhang_ai.image,zhang_ai.rect.x,zhang_ai.rect.y)) screen.blit(zhang_ai,(zhang_ai.rect.x,zhang_ai.rect.y))
pygame.display.update()#保存 pygame.display.update()#保存
......
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