-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTiming.py
59 lines (28 loc) · 916 Bytes
/
Timing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from STL import Time
_TimeSnapshot_Start = int;
_TimeSnapshot_End = int;
_DeltaTime_NS = int;
_DeltaTime_S = float();
def TakeStartSnapshot() :
global _TimeSnapshot_Start; _TimeSnapshot_Start = Time.time_ns()
def TakeEndingSnapshot() :
global _TimeSnapshot_End; _TimeSnapshot_End = Time.time_ns()
def GetDeltaTime() -> float :
global _DeltaTime_S;
return _DeltaTime_S
def Update() :
global _DeltaTime_NS, _DeltaTime_S, _TimeSnapshot_End, _TimeSnapshot_Start
_DeltaTime_NS = _TimeSnapshot_End - _TimeSnapshot_Start
_DeltaTime_S = _DeltaTime_NS / 1000000000
class Timer :
def __init__(self, _endTime : float) :
self.EndTime = _endTime
def Ended(self) -> bool :
return self.Elapsed >= self.EndTime
def Reset(self) :
self.Elapsed = 0.0
def Tick(self) :
delta = GetDeltaTime();
self.Elapsed = float(self.Elapsed) + delta
Elapsed = 0.0
EndTime = 0.0