Module MyGameTimer
[hide private]
[frames] | no frames]

Source Code for Module MyGameTimer

 1  from MyScene import MY_SingleScene 
 2   
3 -class MY_SingleTimer(object):
4 """ 5 singleton class of the ingame timer; to know what time it is ;) 6 7 @cvar NOW: the current time in the game 8 @type NOW: Float 9 @cvar AGO: the last set current game time 10 @type AGO: Float 11 """ 12 13 __instance = None # the unique instance 14 NOW = 0 15 AGO = 0 16
17 - def __new__(self, *args, **kargs):
18 if self.__instance is None: 19 self.__instance = object.__new__(self, *args, **kargs) 20 21 # __init__ section 22 #self.NOW = 0 23 #self.AGO = 0 24 25 return self.__instance
26
27 - def __init__(self):
28 pass
29
30 - def setCurrentTime(self, scene):
31 """ 32 sets the current game time 33 34 @type scene: KX_Scene 35 @param scene: the blender game scene where all objects are bind to 36 """ 37 38 self.NOW = scene.objects["OBcenter"]["now"]
39
40 - def setPassedTime(self, scene):
41 """ 42 sets the iassed ingame time 43 44 @type scene: KX_Scene 45 @param scene: the blender game scene where all objects are bind to 46 """ 47 48 self.AGO = self.NOW
49