X-Git-Url: https://git.ctpug.org.za/?p=naja.git;a=blobdiff_plain;f=naja%2Futils.py;h=7ad4f582c2188a9c6fdcc914fa535eddd70fdc3f;hp=d5d17cc6067276a8649369c625893872388760fe;hb=3ce25dac7ca325c83574240741294666b53613a4;hpb=d26dffb73ba125fc76931375365b10060cf5d892 diff --git a/naja/utils.py b/naja/utils.py index d5d17cc..7ad4f58 100644 --- a/naja/utils.py +++ b/naja/utils.py @@ -37,3 +37,18 @@ 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.ticks = 0 + self.on = False + + def tick(self): + self.ticks += 1 + if self.ticks >= self.rate: + self.on = not self.on + self.ticks = 0 + return True + return False