Commit 1fcdd688 by BellCodeEditor

save project

parent be4581a9
Showing with 6 additions and 0 deletions
...@@ -35,6 +35,8 @@ rect.y = 500 - rect.height ...@@ -35,6 +35,8 @@ rect.y = 500 - rect.height
road_x = 0 road_x = 0
background_x = 0 background_x = 0
gamestate = True gamestate = True
score = 0
sprite = 1
class Player(pygame.sprite.Sprite): class Player(pygame.sprite.Sprite):
def __init__(self,image): def __init__(self,image):
...@@ -101,6 +103,10 @@ while True: ...@@ -101,6 +103,10 @@ while True:
sprite.kill() sprite.kill()
if pygame.sprite.collide_rect(wukong,obstacle): if pygame.sprite.collide_rect(wukong,obstacle):
gamestate = False gamestate = False
else:
if sprite.rect.x + obstacle.rect.width < wukong.rect.x:
score += sprite(score)
sprite = 0
# 创建障碍物对象 # 创建障碍物对象
Group(obstacle = Block(bush,stone,cacti)) Group(obstacle = Block(bush,stone,cacti))
......
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