def onUpdate(self): self.gameObject.aggressive = True if self.movingUp: if self.active: self.gameObject.getComponent(Physics).velocity = Vector2( 0, 50) else: self.gameObject.aggressive = False if self.gameObject.transform.position.y >= self.startPositionY + 24: self.gameObject.getComponent(Physics).velocity = Vector2( 0, 0) elif not self.movingUp: self.gameObject.getComponent(Physics).velocity = Vector2( 0, -50) if self.gameObject.transform.position.y <= self.startPositionY: self.gameObject.getComponent(Physics).velocity = Vector2( 0, 0) self.gameObject.aggressive = False if not self.active: Timer.remove(self.hideTimer)
def onCollisionEnter(self, other, side): if "Player" in other.tags: Timer.remove(self.walkTimer) if side == Sides.TOP_SIDE: self.script.state = KoopaTroopaScript.Stomped(self.script) else: self.script.state = KoopaTroopaScript.Bowling(self.script, other)
def decrement(self): self.time -= 1 self.text = "TIME\n{:03d}".format(self.time) if self.time == 100: Resources.bgMusic.pause() p = Resources.hurryUp.play() p.volume = 0.15 def f(): setBgMusic(self.fastMusic).play() Resources.bgMusic.pitch = 1.05 p.set_handler("on_player_eos", f) if self.time <= 0: Timer.remove(self.countdown) players = World.findByTag("Player") for player in players: # TODO: Just die player.state.downgrade()
def active(self, val): if val is True and self._active is False: Timer.remove(self.showUpTimer) def goUp(): self.movingUp = True self.showUpTimer = Timer.add(goUp, (), 2000, 4000, -1) Timer.remove(self.hideTimer) def goDown(): self.movingUp = False self.hideTimer = Timer.add(goDown, (), 0, 4000, -1) if val is False and self._active is True: Timer.remove(self.showUpTimer) Timer.remove(self.hideTimer) self._active = val
def restart(self): Timer.remove(self.countdown) self.countdown = Timer.add(self.decrement, (), 400, 400, -1)
def stop(self): Timer.remove(self.countdown)
def onDestroy(self): Timer.remove(self.walkTimer)
def onDestroy(self): Timer.remove(self.recoverTimer)
def onCollisionEnter(self, other, side): if "Player" in other.tags: Timer.remove(self.recoverTimer) self.script.state = KoopaTroopaScript.Bowling(self.script, other)
from gameengine.core.Timer import Timer from time import sleep def fun1(text): print(text) t1 = Timer.add(fun1, ("1"), 1000, 500, 3) t2 = Timer.add(fun1, ("2"), 750, 500, -1) t3 = Timer.add(fun1, ("3"), 100, 1000, 1) t4 = Timer.add(fun1, ("2"), 750, 500, -1) Timer.remove(t4) while True: Timer.tick() sleep(0.01)
def onDestroy(self): Timer.remove(self.showUpTimer) Timer.remove(self.hideTimer) from gameengine.core.World import World World.findByTag("Score")[0].add(100)