24 lines
908 B
Python
24 lines
908 B
Python
from gamedata.objects.base import BaseObject
|
|
from gamedata.objects.ingame.lemmings import Lemming
|
|
|
|
import random
|
|
|
|
class Spawner(BaseObject):
|
|
def __init__(self,game,tiles,speedmargin=5):
|
|
spawnpoint = random.choice(tiles.spawns)
|
|
super().__init__(spawnpoint[0],spawnpoint[1],game)
|
|
self.sprite = game.sprite_lib["lemmings/shadow.png"]
|
|
self.speedmargin = speedmargin
|
|
self.timer = game.lib.Timer(3) # Seconds of telegraph before spawning the lemming
|
|
|
|
def step(self):
|
|
if self.timer.tick(self.game.dt):
|
|
lemming = Lemming(self.rect[0],self.rect[1],self.game,speedmargin=self.speedmargin)
|
|
lemming.move(-lemming.rect[2]/2,-lemming.rect[3]/2)
|
|
self.game.gameloop.summon(lemming)
|
|
self.game.gameloop.delid(self.id)
|
|
|
|
def draw(self):
|
|
self.game.lib.drawcenter(self.game,self.sprite,self.rect[0],self.rect[1])
|
|
|