-
Notifications
You must be signed in to change notification settings - Fork 1
/
play_game.py
31 lines (23 loc) · 908 Bytes
/
play_game.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 import Game
from game import Renderer
from time import time
def main():
renderer = Renderer()
game = Game(num_chunks=10, seed=None)
renderer.new_game_setup(game)
while renderer.running:
keys, req = renderer.get_input()
# Check if user is trying to restart this life by ending the life of another / generate new game for the folks of whom you've kidnapped
if req in [renderer.RESTART, renderer.NEW_GAME]:
seed = game.level.seed if req == renderer.RESTART else int(time())
game = Game(num_chunks=10, seed=seed)
renderer.new_game_setup(game)
continue
game.update(keys)
if game.game_over:
game = Game(num_chunks=10, seed=game.level.seed)
renderer.new_game_setup(game)
continue
renderer.draw_state(game, keys)
if __name__ == "__main__":
main()