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-05-24 13:10:10 +02:00
|
|
|
self.ui = None
|
|
|
|
|
|
|
|
def initialize_interface(self, inventory):
|
|
|
|
self.ui = UserInterface(self.camera.window, 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
|
2021-04-19 00:07:40 +02:00
|
|
|
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()
|