Fixed speed variation

This commit is contained in:
theo@manjaro 2021-09-15 21:09:15 +02:00
parent 7930b72fc8
commit afb9425069
2 changed files with 4 additions and 2 deletions

View File

@ -7,8 +7,9 @@ class Lemming(BaseObject):
self.direction = random.randint(0,360)
self.holdrect = self.rect.copy()
self.holdradius = 80
print(speedmargin)
self.holdrect = self.holdrect.inflate(self.holdradius,self.holdradius)
self.basespeed = max(30,40+random.randint(-speedmargin,speedmargin)) # Speed that he normally walks by
self.basespeed = max(20,40+random.randint(-speedmargin,speedmargin)) # Speed that he normally walks by
self.holdtimer = game.lib.Timer(2.5) # Max seconds of holding
self.normalspeed = self.basespeed # Speed "objective"
self.speed = 0 # Current speed, leaning towards objective speed

View File

@ -12,7 +12,7 @@ class Manager(BaseObject):
self.basetime = 10
self.steptime = 2
self.speedmargin = 7
self.stepmargin = 2
self.speedstep = 2.2
self.spawntimer = game.lib.Timer(self.basetime) # Time elapsing each lemming spawn
self.deathtimer = game.lib.Timer(1) # Time between each life loss
self.started = False
@ -47,6 +47,7 @@ class Manager(BaseObject):
if (self.lives>0 and nblemmings>0):
if self.spawntimer.tick(self.game.dt):
self.game.gameloop.summon(Spawner(self.game,self.tiles,speedmargin=int(self.speedmargin+0.5)))
self.speedmargin+=self.speedstep
self.spawntimer = self.game.lib.Timer(self.basetime+nblemmings*self.steptime)
else:
# Game over