from gamedata.objects.base import BaseObject from gamedata.objects.ingame.spawner import Spawner from gamedata.objects.ingame.tiles import Tiles class Manager(BaseObject): def __init__(self,game): super().__init__(0,0,game) self.score = 0 self.lives = 5 self.basetime = 10 self.steptime = 2 self.speedmargin = 6 self.stepmargin = 0.4 self.spawntimer = game.lib.Timer(self.basetime) # Time elapsing each lemming spawn self.deathtimer = game.lib.Timer(1) # Time betwin each life loss self.invincible = False self.scoreratio = 0.4 # Points earned per seconds and per lemming # Summon the tiles self.tiles = Tiles(50,50,game) game.gameloop.summon(self.tiles) # Spawn the first one self.game.gameloop.summon(Spawner(self.game,self.tiles)) def step(self): nblemmings = len(self.game.gameloop.findname("Lemming")) # Updating score for i in range(nblemmings): self.score+=self.scoreratio*self.game.dt # Spawning more lemmings if self.lives>0 and nblemmings>0 and self.spawntimer.tick(self.game.dt): self.game.gameloop.summon(Spawner(self.game,self.tiles,speedmargin=int(self.speedmargin+0.5))) self.basetime+=self.steptime self.spawntimer = self.game.lib.Timer(self.basetime) self.speedmargin+=self.stepmargin if self.invincible: if self.deathtimer.tick(self.game.dt): self.invincible = False print(self.lives) def death(self): if not self.invincible: self.lives-=1 self.invincible = True def draw(self): pass