Colors unlock with highscore

This commit is contained in:
theo@manjaro 2021-09-18 18:27:52 +02:00
parent 53b81bb48c
commit 0f8d3f6883
14 changed files with 22 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -129,3 +129,11 @@ def savesettings(dirname,bgm=1,sfx=1,filename="settings.ini"):
with open(filepath,'w') as configfile: with open(filepath,'w') as configfile:
config.write(configfile) config.write(configfile)
def getunlocks(highscore):
unlocks = {"normal":["base"],"specials":[]}
if highscore>=50:
unlocks["normal"].append("green")
if highscore>=250:
unlocks["normal"].append("blue")
return unlocks

View File

@ -16,6 +16,8 @@ class MenuBackground(BaseObject):
# Pinmik falling # Pinmik falling
self.pinmiktimer = game.lib.Timer(1) self.pinmiktimer = game.lib.Timer(1)
unlocks = game.lib.getunlocks(game.globals["highscore"])
self.skins = unlocks["normal"]+unlocks["specials"]
def step(self): def step(self):
@ -27,7 +29,7 @@ class MenuBackground(BaseObject):
if self.pinmiktimer.tick(self.game.dt): if self.pinmiktimer.tick(self.game.dt):
self.pinmiktimer = game.lib.Timer(1+random.random()) self.pinmiktimer = game.lib.Timer(1+random.random())
self.game.gameloop.summon(FallingPinmik(game)) self.game.gameloop.summon(FallingPinmik(game,skins=self.skins))
def draw(self): def draw(self):
game = self.game game = self.game

View File

@ -36,15 +36,19 @@ class Manager(BaseObject):
# Summon the tiles # Summon the tiles
self.tiles = Tiles(288,0,game) self.tiles = Tiles(288,0,game)
game.gameloop.summon(self.tiles) game.gameloop.summon(self.tiles)
# Spawn the first batch
self.game.gameloop.summon(Spawner(self.game,self.tiles))
self.game.gameloop.summon(Spawner(self.game,self.tiles))
self.game.gameloop.summon(Spawner(self.game,self.tiles))
# Demo # Demo
self.demo = None self.demo = None
self.demotimer = game.lib.Timer(4) self.demotimer = game.lib.Timer(4)
# Unlocks
self.skins = game.lib.getunlocks(self.game.globals["highscore"])
# Spawn the first batch
self.game.gameloop.summon(Spawner(self.game,self.tiles,skins=self.skins))
self.game.gameloop.summon(Spawner(self.game,self.tiles,skins=self.skins))
self.game.gameloop.summon(Spawner(self.game,self.tiles,skins=self.skins))
def step(self): def step(self):
nblemmings = len(self.game.gameloop.findname("Lemming")) + len(self.game.gameloop.findname("Spawner")) nblemmings = len(self.game.gameloop.findname("Lemming")) + len(self.game.gameloop.findname("Spawner"))
# Updating score # Updating score
@ -53,7 +57,7 @@ class Manager(BaseObject):
# Spawning more lemmings # Spawning more lemmings
if (self.lives>0 and nblemmings>0): if (self.lives>0 and nblemmings>0):
if self.spawntimer.tick(self.game.dt): if self.spawntimer.tick(self.game.dt):
self.game.gameloop.summon(Spawner(self.game,self.tiles,speedmargin=int(self.speedmargin+0.5))) self.game.gameloop.summon(Spawner(self.game,self.tiles,speedmargin=int(self.speedmargin+0.5),skins=self.skins))
self.speedmargin+=self.speedstep self.speedmargin+=self.speedstep
self.spawntimer = self.game.lib.Timer(self.basetime+nblemmings*self.steptime) self.spawntimer = self.game.lib.Timer(self.basetime+nblemmings*self.steptime)
else: else:

View File

@ -4,7 +4,7 @@ from gamedata.objects.ingame.lemmings import Lemming
import random import random
class Spawner(BaseObject): class Spawner(BaseObject):
def __init__(self,game,tiles,speedmargin=5,skins={"normal":["base","green"],"specials":[]}): def __init__(self,game,tiles,speedmargin=5,skins={"normal":["base"],"specials":[]}):
spawnpoint = random.choice(tiles.spawns) spawnpoint = random.choice(tiles.spawns)
super().__init__(spawnpoint[0],spawnpoint[1],game) super().__init__(spawnpoint[0],spawnpoint[1],game)
self.sprite = game.sprite_lib["lemmings/shadow.png"].copy() self.sprite = game.sprite_lib["lemmings/shadow.png"].copy()