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-06-19 00:09:14 +02:00
|
|
|
from survival.game.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
|
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-06-20 16:30:30 +02:00
|
|
|
if self.ui.initialized:
|
|
|
|
self.ui.update()
|
|
|
|
self.ui.draw()
|