-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtimer.py
More file actions
42 lines (29 loc) · 764 Bytes
/
timer.py
File metadata and controls
42 lines (29 loc) · 764 Bytes
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
import time
class Timer:
def __init__(self):
self.beginning_time = 0
self.time_length = 0
def start(self, time_length):
self.beginning_time = time.time()
self.time_length = time_length
def get(self):
"""
decrements from time_length to 0
"""
current_time = time.time()
time_difference = self.time_length - (current_time - self.beginning_time)
return time_difference
@property
def ended(self):
return self.get() <= 0
class Ticker:
"""
literally just stores a unique tick lmao
"""
def __init__(self):
self._tick = 0
def update(self):
self._tick += 1
@property
def tick(self):
return self._tick