python
from demiurge import World, Entity, Component, System
class PositionComponent(Component):
def __init__(self, x, y):
self.x = x
self.y = y
class RenderComponent(Component):
def __init__(self, sprite):
self.sprite = sprite
class MovementSystem(System):
def __init__(self):
self.required_components = [PositionComponent]
def update(self, world, entity):
position = entity.get_component(PositionComponent)
position.x += 1
position.y += 1
class RenderSystem(System):
def __init__(self):
self.required_components = [PositionComponent, RenderComponent]
def update(self, world, entity):
position = entity.get_component(PositionComponent)
render = entity.get_component(RenderComponent)
print(f"Render: {render.sprite} at ({position.x}, {position.y})")
world = World()
entity = Entity()
entity.add_component(PositionComponent(0, 0))
entity.add_component(RenderComponent("player.png"))
world.add_entity(entity)
world.add_system(MovementSystem())
world.add_system(RenderSystem())
while True:
world.update()