AI-Project/survival/systems/draw_system.py

22 lines
783 B
Python
Raw Normal View History

2021-03-28 18:05:52 +02:00
from survival import esper
from survival.components.position_component import PositionComponent
from survival.components.sprite_component import SpriteComponent
2021-05-24 13:10:10 +02:00
from survival.user_interface import UserInterface
2021-03-28 18:05:52 +02:00
class DrawSystem(esper.Processor):
2021-03-28 18:42:04 +02:00
def __init__(self, camera):
2021-03-28 18:05:52 +02:00
self.camera = camera
2021-06-06 19:55:55 +02:00
self.ui = UserInterface(self.camera.window)
2021-05-24 13:10:10 +02:00
def initialize_interface(self, inventory):
2021-06-06 19:55:55 +02:00
self.ui.load_inventory(inventory)
2021-03-28 18:05:52 +02:00
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)
2021-03-28 18:05:52 +02:00
self.camera.draw(sprite.image)
2021-05-24 13:10:10 +02:00
self.ui.update()
self.ui.draw()