Stepwise/source/engine.py
2025-03-20 10:56:10 +11:00

34 lines
851 B
Python

from typing import Any, Iterable
from tcod.context import Context
from tcod.console import Console
from entity import Entity
from floor_map import FloorMap #TODO: replace with "DungeonMap"
class Engine:
def __init__(self, floor_map: FloorMap):
from event_handler import EventHandler
self.event_handler = EventHandler(self)
self.player = Entity(0, 0, "@", (255, 255, 255))
self.floor_map = floor_map
def handle_events(self, events: Iterable[Any]) -> None:
for event in events:
action = self.event_handler.dispatch(event)
if action is None:
continue
action.apply(self)
def render(self, context: Context, console: Console) -> None:
self.floor_map.render(console)
console.print(self.player.x, self.player.y, self.player.char, fg=self.player.color)
#send to the screen
context.present(console)
console.clear()