Commit a61a2238 by BellCodeEditor

auto save

parent 277becc5
Showing with 8 additions and 0 deletions
......@@ -17,6 +17,7 @@ class Block(pygame.sprite.Sprite):
self.rect=self.image.get_rect()
self.rect.x=1000
self.rect.y=500-self.rect.height
self.score=1
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
......@@ -32,6 +33,7 @@ hero = [pygame.image.load('hero1.png'),
pygame.image.load('hero3.png'),
pygame.image.load('hero4.png'),
pygame.image.load('hero5.png')]
myfont=pygame.font.Font('STKAITI.TTF')
road_x=0
bg_x=0
index = 0
......@@ -43,6 +45,7 @@ time=0 #精灵之间的间隔时间
#obstacle = Block(stone,cacti,bush)
block_list=pygame.sprite.Group() #创建一个精灵组
gamestate=True
score=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -104,6 +107,10 @@ while True:
gameover=pygame.image.load('gameover.png')
screen.blit(gameover,(400,200))
gamestate=False
else:
if sprite.rect.x+sprite.rect.width<wukong.rect.x:
score+=sprite.score
sprite.score=0
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ 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