- added gameOver method and pic

master
Steve Clement 2014-08-30 23:27:24 +02:00
parent f0d6fe8784
commit 97b59f5218
2 changed files with 9 additions and 0 deletions

View File

@ -69,6 +69,11 @@ class TheGame:
self.click = pygame.mixer.Sound("audio/click.wav") self.click = pygame.mixer.Sound("audio/click.wav")
return self.click return self.click
def gameOver(self,screen,gameOverImage):
screen.blit(pygame.transform.scale(gameOverImage, (800, 600)), (0, 0))
pygame.display.flip()
pygame.time.wait(3000)
def main(self): def main(self):
clock = pygame.time.Clock() clock = pygame.time.Clock()
@ -87,6 +92,8 @@ class TheGame:
# I don't know, should we move this text out of the way? # I don't know, should we move this text out of the way?
game_over = font.render('GAME OVER', 0, RED) game_over = font.render('GAME OVER', 0, RED)
gameOverImage = pygame.image.load("img/gameOver.png")
# initialize the game canvas # initialize the game canvas
screen = pygame.display.set_mode(size) screen = pygame.display.set_mode(size)
@ -135,6 +142,7 @@ class TheGame:
screen.blit(game_over, (screen_width/3, screen_height/2)) screen.blit(game_over, (screen_width/3, screen_height/2))
displaytime = 'Timed out!' displaytime = 'Timed out!'
pygame.display.flip() pygame.display.flip()
game.gameOver(screen,gameOverImage)
continue continue
else: else:
displaytime = timeleft displaytime = timeleft
@ -178,6 +186,7 @@ class TheGame:
# Had enough of this? # Had enough of this?
if event.type == pygame.QUIT: if event.type == pygame.QUIT:
running = False running = False
game.gameOver(screen,gameOverImage)
pygame.quit() pygame.quit()
sys.exit() sys.exit()

BIN
img/gameOver.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 KiB