Commit 83bafb2d by BellCodeEditor

save project

parent 287f93fa
Showing with 17 additions and 4 deletions
...@@ -17,17 +17,28 @@ hero = [pygame.image.load('hero1.png'), ...@@ -17,17 +17,28 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'), pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')] pygame.image.load('hero5.png')]
class Block(pygame.sprite.Sprite):
def __init__(self,image1,image2,image3):
super().__init__()
self.image=random.choice([image1,image2,image3])
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
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.image=image
self.rect=self.image.get_rect() self.rect=self.image.get_rect()
self.rect.x=150
self.rect.y=400
group=pygame.sprite.Group()
index = 0 index = 0
y = 400 y = 400
jumpState = "runing" jumpState = "runing"
t = 30 t = 30
obstacle = random.choice([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
...@@ -76,8 +87,10 @@ while True: ...@@ -76,8 +87,10 @@ while True:
rect.x = 1000 rect.x = 1000
rect.y = 500 - rect.height rect.y = 500 - rect.height
rect.x -= 8 rect.x -= 8
screen.blit(obstacle, (rect.x, rect.y)) for sprite in group:
screen.blit(obstacle, (rect.x, rect.y))
pygame.sprite.collide_rect()
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPS.tick(30) FPS.tick(30)
pygame.sprite.collide_rect()
\ No newline at end of file \ 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