30 lines
905 B
Python
30 lines
905 B
Python
|
from pygame.time import Clock
|
||
|
|
||
|
from .servers.graphics import GraphicsServer
|
||
|
from .servers.sound import SoundServer
|
||
|
from .servers.physics import PhysicsServer
|
||
|
from .servers.input import InputServer, StopException
|
||
|
from .scene_manager import SceneManager
|
||
|
|
||
|
|
||
|
class Game:
|
||
|
def __init__(self, start_scene):
|
||
|
self._graphics_server = GraphicsServer()
|
||
|
self._sound_server = SoundServer()
|
||
|
self._physics_server = PhysicsServer()
|
||
|
self._input_server = InputServer()
|
||
|
self._scene_manager = SceneManager(start_scene)
|
||
|
|
||
|
def run(self):
|
||
|
clock = Clock()
|
||
|
while True:
|
||
|
try:
|
||
|
self._input_server.step()
|
||
|
except StopException:
|
||
|
break
|
||
|
self._scene_manager.step()
|
||
|
self._physics_server.step()
|
||
|
self._sound_server.step()
|
||
|
self._graphics_server.step()
|
||
|
clock.tick(60)
|