Commit fba9f4c2 by BellCodeEditor

save project

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