Commit fba9f4c2 by BellCodeEditor

save project

parent 6e3fd883
Showing with 16 additions and 18 deletions
...@@ -15,11 +15,11 @@ class Block(pygame.sprite.Sprite): ...@@ -15,11 +15,11 @@ 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 Block(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()
...@@ -63,10 +63,10 @@ while True: ...@@ -63,10 +63,10 @@ while True:
if event.key == locals.K_SPACE: if event.key == locals.K_SPACE:
jumpState = "up" jumpState = "up"
wukong = Player(hero[index]) wukong = Player(hero[index])
if jumpState == "runing": if jumpState == "runing":
index += 1 index += 1
if index >= 5: if index >= 5:
index = 0 index = 0
if gamestate ==True: if gamestate ==True:
if jumpState == "up": if jumpState == "up":
if t > 0: if t > 0:
...@@ -95,24 +95,22 @@ while True: ...@@ -95,24 +95,22 @@ while True:
if road_x<=-1000: if road_x<=-1000:
road_x = 0 road_x = 0
screen.blit(road, (road_x, 500)) screen.blit(road, (road_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
r = random.randint(0,100) num = random.randint(0,50)
if r > 40: if num > 20:
abstacle = Block(bush,cacti,stone) abstacle = Block(bush,cacti,stone)
block_list.add(abstacle) block_list.add(abstacle)
time = 0 for sprite in block_list:
sprite.rect.x -= 8
for prop in block_list: screen.blit(sprite.image,(sprite.rect.x,sprite.rect.y))
prop.rect.x -= 8 if sprite.rect.x<=0-sprite.rect.width:
screen.blit(prop.image,(prop.rect.x,prop.rect.y)) sprite.kill()
if prop.rect.x<=0-prop.rect.width:
prop.kill()
if pygame.sprite.collide_rect(wukong,sprite): if pygame.sprite.collide_rect(wukong,sprite):
gameover = pygame.image.load('gameover.pog') gameover = pygame.image.load('gameover.png')
screen.blit(gameover,(400,200)) screen.blit(gameover,(400,200))
gamestate = False gamestate = False
......
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