Commit 1e23e9d8 by BellCodeEditor

save project

parent b1df6cd9
Showing with 9 additions and 6 deletions
...@@ -11,6 +11,7 @@ class Block(pygame.sprite.Sprite): ...@@ -11,6 +11,7 @@ class Block(pygame.sprite.Sprite):
self.rect = self.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
self.score = 1
class player(pygame.sprite.Sprite): class player(pygame.sprite.Sprite):
def __init__ (self,image): def __init__ (self,image):
...@@ -31,6 +32,7 @@ road = pygame.image.load('road.png') # 路 ...@@ -31,6 +32,7 @@ road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头 stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌 cacti = pygame.image.load('cacti.png') # 仙人掌
bush = pygame.image.load('bush.png') # 灌木丛 bush = pygame.image.load('bush.png') # 灌木丛
basic_font = pygame.font.Font('STKAITI.TTF',18)
hero = [pygame.image.load('hero1.png'), hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero2.png'), pygame.image.load('hero2.png'),
pygame.image.load('hero3.png'), pygame.image.load('hero3.png'),
...@@ -44,9 +46,9 @@ nu = 30 ...@@ -44,9 +46,9 @@ nu = 30
road_x=0 road_x=0
bg_x = 0 bg_x = 0
time = 0 time = 0
#zhuangzhe = Block(stone,cacti,bush)
block_list = pygame.sprite.Group() block_list = pygame.sprite.Group()
huabu = True huabu = True
score = 0
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -96,10 +98,6 @@ while True: ...@@ -96,10 +98,6 @@ while True:
screen.blit(wukong.image, (150, y)) screen.blit(wukong.image, (150, y))
# 刷新画面 # 刷新画面
#if zhuangzhe.rect.x <= 0-zhuangzhe.rect.width:
#zhuangzhe = Block(stone,cacti,bush)
#zhuangzhe.rect.x -= 8
time += 1 time += 1
if time >= 60: if time >= 60:
time = 0 time = 0
...@@ -116,8 +114,13 @@ while True: ...@@ -116,8 +114,13 @@ while True:
gameover = pygame.image.load('gameover.png') gameover = pygame.image.load('gameover.png')
screen.blit(gameover,(400,200)) screen.blit(gameover,(400,200))
huabu = False huabu = False
else:
if (prop.rect.x + prop.rect.width) < wukong.rect.x :
score += sprite.score
scoreSurf = basic_font.render("分数"+str(score),True,(255,255,255))
screen.blit(scoreSurf,(880,20))
#screen.blit(zhuangzhe.image, (zhuangzhe.rect.x, zhuangzhe.rect.y))
pygame.display.update() pygame.display.update()
FPS.tick(60) FPS.tick(60)
......
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