24 lines
649 B
Python
24 lines
649 B
Python
from .server import Server
|
|
|
|
from pygame import display
|
|
|
|
|
|
class GraphicsServer(Server):
|
|
def __init__(self, size=(640, 480)):
|
|
super().__init__()
|
|
display.init()
|
|
self.window = display.set_mode(size)
|
|
|
|
def register_component(self, component):
|
|
super().register_component(component)
|
|
self._components.sort(key=lambda e: e.z)
|
|
|
|
def step(self):
|
|
for component in self._components:
|
|
self.window.blit(component.surf,
|
|
(component.parent.x, component.parent.y))
|
|
display.flip()
|
|
|
|
def resize(self, new_size):
|
|
self.window = display.set_mode(new_size)
|