bg
[sso] / shaken_and_spit_out / pgfw / TimeFilter.py
1 from pygame.time import get_ticks
2
3 from GameChild import GameChild
4
5 class TimeFilter(GameChild):
6
7 def __init__(self, parent):
8 GameChild.__init__(self, parent)
9 self.ticks = self.unfiltered_ticks = self.last_ticks = get_ticks()
10 self.open()
11
12 def close(self):
13 self.closed = True
14
15 def open(self):
16 self.closed = False
17
18 def get_ticks(self):
19 return self.ticks
20
21 def get_unfiltered_ticks(self):
22 return self.unfiltered_ticks
23
24 def get_last_ticks(self):
25 return self.last_ticks
26
27 def get_last_frame_duration(self):
28 return self.last_frame_duration
29
30 def update(self):
31 ticks = get_ticks()
32 self.last_frame_duration = duration = ticks - self.last_ticks
33 if not self.closed:
34 self.ticks += duration
35 self.unfiltered_ticks += duration
36 self.last_ticks = ticks