AI-Project/survival/systems/draw_system.py
2021-06-20 16:30:30 +02:00

23 lines
832 B
Python

from survival import esper
from survival.components.position_component import PositionComponent
from survival.components.sprite_component import SpriteComponent
from survival.game.user_interface import UserInterface
class DrawSystem(esper.Processor):
def __init__(self, camera):
self.camera = camera
self.ui = UserInterface(self.camera.window)
def initialize_interface(self, inventory):
self.ui.load_inventory(inventory)
def process(self, dt):
for ent, (sprite, pos) in self.world.get_components(SpriteComponent, PositionComponent):
sprite.image.pos = pos.position
sprite.image.origin = (32 * pos.direction.value, 0)
self.camera.draw(sprite.image)
if self.ui.initialized:
self.ui.update()
self.ui.draw()