-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
executable file
·55 lines (45 loc) · 1.48 KB
/
app.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
#!/usr/bin/env python3
"""
app.py
Copyright 2023 Steve Palmer
"""
import logging.config
import pyglet
import numpy as np
from utils import traced_methods
from maze import Maze
from player import Player
from game_controller import GameController
from plan_view import PlanView
from tunnel_view import TunnelView
from tunnel_view_2 import TunnelView2
@traced_methods
class Main:
def __init__(self, size_x: int = None, size_y: int = None):
if size_x is None:
size_x = 10
if size_y is None:
size_y = size_x * 8 // 10
self.maze = Maze(np.array([size_x, size_y]))
self.build = self.maze.build()
self.game_controller = GameController(maze=self.maze, caption="Maze 3D")
start_view = self.game_controller.add_view(PlanView)
self.game_controller.add_view(TunnelView)
self.game_controller.add_view(TunnelView2)
self.game_controller.current_view_index = start_view
def update(self, dt):
try:
next(self.build)
except StopIteration:
pyglet.clock.unschedule(self.update)
self.player = Player(self.maze)
self.game_controller.add_player(self.player)
def go(self):
pyglet.clock.schedule_interval(self.update, 0.02)
pyglet.app.run()
if __name__ == "__main__":
from pathlib import Path
logging_config = Path("logging.conf")
if logging_config.exists():
logging.config.fileConfig(logging_config.open())
Main().go()