X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Futils.py;h=925442a7a12eef328f723b40f026070a37214f7d;hb=refs%2Fheads%2Fmaster;hp=d5d17cc6067276a8649369c625893872388760fe;hpb=652ccba57669197aada1143ad0f61acb59578cd1;p=naja.git diff --git a/naja/utils.py b/naja/utils.py index d5d17cc..925442a 100644 --- a/naja/utils.py +++ b/naja/utils.py @@ -37,3 +37,21 @@ def warp_to_game_state(game_state): from naja.scenes.game import GameScene LoadGameEvent.post(game_state) SceneChangeEvent.post(GameScene) + + +class Flashlight(object): + def __init__(self, rate): + self.rate = rate + self.reset() + + def tick(self): + self.ticks += 1 + if self.ticks >= self.rate: + self.on = not self.on + self.ticks = 0 + return True + return False + + def reset(self): + self.ticks = 0 + self.on = True