This repository has been archived on 2019-12-09. You can view files and clone it, but cannot push or open issues or pull requests.
pacman2/engine/game.py
2019-12-09 12:36:42 +01:00

33 lines
954 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:
cur_tick = 0
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()
Game.cur_tick += 1
clock.tick(60)