-
Notifications
You must be signed in to change notification settings - Fork 1
/
engine.py
54 lines (48 loc) · 1.43 KB
/
engine.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
from settings import *
from level_data import LevelData
from map_renderer import MapRenderer
from bsp.bsp_builder import BSPTreeBuilder
from bsp.bsp_traverser import BSPTreeTraverser
from camera import Camera
from input_handler import InputHandler
from view_renderer import ViewRenderer
from time import perf_counter
class Engine:
def __init__(self, app):
self.app = app
#
self.level_data = LevelData(self)
self.bsp_builder = BSPTreeBuilder(self)
#
self.camera = Camera(self)
self.input_handler = InputHandler(self)
#
self.bsp_traverser = BSPTreeTraverser(self)
self.map_renderer = MapRenderer(self)
self.view_renderer = ViewRenderer(self)
def update(self):
self.camera.pre_update()
#
self.input_handler.update()
#
self.camera.update()
self.bsp_traverser.update()
# start = perf_counter()
self.view_renderer.update()
# print(perf_counter() - start)
def draw_2d(self):
self.map_renderer.draw() if self.map_renderer.should_draw else ray.draw_fps(10, 10)
def draw_3d(self):
ray.begin_mode_3d(self.camera.m_cam)
#
self.view_renderer.draw()
#
ray.end_mode_3d()
def draw(self):
ray.begin_drawing()
#
ray.clear_background(BLACK_COLOR)
self.draw_3d()
self.draw_2d()
#
ray.end_drawing()