|
|
|
@ -16,12 +16,25 @@ class GameOver(BaseObject):
|
|
|
|
|
|
|
|
|
|
# Updating highscore
|
|
|
|
|
self.highscore = False
|
|
|
|
|
self.newunlocks = []
|
|
|
|
|
if game.globals["highscore"]<game.globals["score"]:
|
|
|
|
|
self.pastunlocks = game.lib.getunlocks(game.globals["highscore"])
|
|
|
|
|
self.currentunlocks = game.lib.getunlocks(game.globals["score"])
|
|
|
|
|
game.globals["highscore"] = game.globals["score"]
|
|
|
|
|
self.highscore = True
|
|
|
|
|
|
|
|
|
|
self.game.lib.savescore(self.game.datadir,self.game.globals["highscore"],self.game.dataname)
|
|
|
|
|
|
|
|
|
|
# Get if there's an unlock
|
|
|
|
|
self.newunlocks = []
|
|
|
|
|
self.unlocksprites = {}
|
|
|
|
|
for unlocktype in ["normal","specials"]:
|
|
|
|
|
for unlock in self.currentunlocks[unlocktype]:
|
|
|
|
|
if not unlock in self.pastunlocks[unlocktype]:
|
|
|
|
|
self.newunlocks.append(unlock)
|
|
|
|
|
sprite = game.sprite_lib["lemmings/"+unlock+"/falling.png"]
|
|
|
|
|
self.unlocksprites[unlock] = game.pygame.transform.scale(sprite,[sprite.get_width()*3,sprite.get_height()*3])
|
|
|
|
|
|
|
|
|
|
self.displayscore = 0
|
|
|
|
|
|
|
|
|
|
self.launched = False
|
|
|
|
@ -31,8 +44,11 @@ class GameOver(BaseObject):
|
|
|
|
|
self.scale = 1
|
|
|
|
|
|
|
|
|
|
# Highscore texts
|
|
|
|
|
self.highscorewhite = game.fontfilebig.render("New Highscore !",False,[255]*3)
|
|
|
|
|
self.highscoreflash = game.fontfilebig.render("New Highscore !",False,[255,230,55])
|
|
|
|
|
text = "New Highscore !"
|
|
|
|
|
if len(self.newunlocks)>0:
|
|
|
|
|
text+=" You unlocked :"
|
|
|
|
|
self.highscorewhite = game.fontfilebig.render(text,False,[255]*3)
|
|
|
|
|
self.highscoreflash = game.fontfilebig.render(text,False,[255,230,55])
|
|
|
|
|
self.flashtimer = game.lib.Timer(0.4)
|
|
|
|
|
|
|
|
|
|
def step(self):
|
|
|
|
@ -68,11 +84,20 @@ class GameOver(BaseObject):
|
|
|
|
|
self.game.lib.drawcenter(self.game,txt,self.game.DISPLAY_WIDTH/2,self.game.DISPLAY_HEIGHT*0.4)
|
|
|
|
|
# Display new highscore
|
|
|
|
|
if self.highscore:
|
|
|
|
|
txt = [self.highscorewhite,self.highscoreflash][self.flashtimer.getloops()%2]
|
|
|
|
|
if not self.launched:
|
|
|
|
|
txt.set_alpha((1-self.launchtimer.getratio())**2*255)
|
|
|
|
|
alpha = (1-self.launchtimer.getratio())**2*255
|
|
|
|
|
else:
|
|
|
|
|
txt.set_alpha(255)
|
|
|
|
|
alpha = 255
|
|
|
|
|
txt = [self.highscorewhite,self.highscoreflash][self.flashtimer.getloops()%2]
|
|
|
|
|
txt.set_alpha(alpha)
|
|
|
|
|
self.game.lib.drawcenter(self.game,txt,self.game.DISPLAY_WIDTH/2,self.game.DISPLAY_HEIGHT*0.6)
|
|
|
|
|
|
|
|
|
|
# Draw unlocks
|
|
|
|
|
for i in range(len(self.newunlocks)):
|
|
|
|
|
posx = self.game.DISPLAY_WIDTH/(len(self.newunlocks)+1)*(i+1)
|
|
|
|
|
posy = self.game.DISPLAY_HEIGHT*0.7
|
|
|
|
|
sprite = self.unlocksprites[self.newunlocks[i]]
|
|
|
|
|
sprite.set_alpha(alpha)
|
|
|
|
|
self.game.lib.drawcenter(self.game,sprite,posx,posy)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|