Animating the lemming falling

This commit is contained in:
theo@manjaro 2021-09-14 16:50:27 +02:00
parent 8547c71d5c
commit e28f8c8958

View File

@ -9,6 +9,8 @@ class Spawner(BaseObject):
super().__init__(spawnpoint[0],spawnpoint[1],game) super().__init__(spawnpoint[0],spawnpoint[1],game)
self.sprite = game.sprite_lib["lemmings/shadow.png"] self.sprite = game.sprite_lib["lemmings/shadow.png"]
self.speedmargin = speedmargin self.speedmargin = speedmargin
self.fallsprite = game.sprite_lib["lemmings/Right/0.png"]
self.distance = game.DISPLAY_HEIGHT
self.timer = game.lib.Timer(3) # Seconds of telegraph before spawning the lemming self.timer = game.lib.Timer(3) # Seconds of telegraph before spawning the lemming
def step(self): def step(self):
@ -19,5 +21,10 @@ class Spawner(BaseObject):
self.game.gameloop.delid(self.id) self.game.gameloop.delid(self.id)
def draw(self): def draw(self):
# Display the lemming falling
currentdistance = self.distance*self.timer.getratio()**2
self.game.lib.drawcenter(self.game,self.fallsprite,self.rect[0],self.rect[1]-currentdistance)
# Draw the shadow
self.game.lib.drawcenter(self.game,self.sprite,self.rect[0],self.rect[1]) self.game.lib.drawcenter(self.game,self.sprite,self.rect[0],self.rect[1])