diff options
Diffstat (limited to 'kennel/engine/components')
| -rw-r--r-- | kennel/engine/components/__init__.py | 0 | ||||
| -rw-r--r-- | kennel/engine/components/component.py | 16 | ||||
| -rw-r--r-- | kennel/engine/components/controllable.py | 13 | ||||
| -rw-r--r-- | kennel/engine/components/position.py | 14 |
4 files changed, 43 insertions, 0 deletions
diff --git a/kennel/engine/components/__init__.py b/kennel/engine/components/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/kennel/engine/components/__init__.py diff --git a/kennel/engine/components/component.py b/kennel/engine/components/component.py new file mode 100644 index 0000000..c8ef2d0 --- /dev/null +++ b/kennel/engine/components/component.py @@ -0,0 +1,16 @@ +from enum import Enum +from abc import abstractmethod + + +class ComponentType(str, Enum): + POSITION = "POSITION" + CONTROLLABLE = "CONTROLLABLE" + + +class Component: + def __init__(self, component_type: ComponentType): + self.component_type = component_type + + @abstractmethod + def dict(self) -> dict: + pass diff --git a/kennel/engine/components/controllable.py b/kennel/engine/components/controllable.py new file mode 100644 index 0000000..49b0557 --- /dev/null +++ b/kennel/engine/components/controllable.py @@ -0,0 +1,13 @@ +from .component import Component, ComponentType + + +class Controllable(Component): + def __init__(self, by: str): + super().__init__(ComponentType.CONTROLLABLE) + self.by = by + + def __repr__(self) -> str: + return f"Controllable(by={self.by})" + + def dict(self) -> dict: + return {"by": self.by} diff --git a/kennel/engine/components/position.py b/kennel/engine/components/position.py new file mode 100644 index 0000000..2a4da4a --- /dev/null +++ b/kennel/engine/components/position.py @@ -0,0 +1,14 @@ +from .component import Component, ComponentType + + +class Position(Component): + def __init__(self, x: float, y: float): + super().__init__(ComponentType.POSITION) + self.x = x + self.y = y + + def __repr__(self) -> str: + return f"Position(x={self.x}, y={self.y})" + + def dict(self) -> dict: + return {"x": self.x, "y": self.y} |
