27 lines
558 B
Python
27 lines
558 B
Python
from engine import Engine
|
|
|
|
from entity import Entity
|
|
|
|
class Action:
|
|
def apply(self, engine: Engine) -> None:
|
|
raise NotImplementedError()
|
|
|
|
class QuitAction(Action):
|
|
def apply(self, engine: Engine) -> None:
|
|
raise SystemExit()
|
|
|
|
class MoveAction(Action):
|
|
def __init__(self, entity: Entity, xdir: int, ydir: int):
|
|
super().__init__()
|
|
self.entity = entity
|
|
self.xdir = xdir
|
|
self.ydir = ydir
|
|
|
|
def apply(self, engine: Engine) -> None:
|
|
x = self.entity.x + self.xdir
|
|
y = self.entity.y + self.ydir
|
|
|
|
#TODO: bounds checks
|
|
|
|
self.entity.set_pos(x, y)
|