-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (23 loc) · 802 Bytes
/
main.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
from game_functions.game_engine import GameEngine
import time
SEC_PER_UPDATE = 1000 / 60 / 1000
def main():
game_engine = GameEngine()
should_continue = True
previous_time = time.time()
lag = 0
while should_continue:
current_time = time.time()
elapsed_time = current_time - previous_time
previous_time = current_time
lag += elapsed_time
while lag >= SEC_PER_UPDATE:
if not game_engine.update():
should_continue = False
break
lag -= SEC_PER_UPDATE
game_engine.draw()
# clear screen after game stopped
game_engine.console_out.write_frame(" " * (game_engine.console_out.console_height * game_engine.console_out.console_width))
if __name__ == '__main__':
main()