Stepwise/source/main.py
2025-03-13 19:50:34 +11:00

40 lines
987 B
Python
Executable File

#!./bin/python
import tcod
from engine import Engine
from entity import Entity
from input_events import EventHandler
def main() -> None:
#Initial values
screen_width = 80
screen_height = 50
tileset = tcod.tileset.load_tilesheet("assets/dejavu10x10_gs_tc.png", 32, 8, tcod.tileset.CHARMAP_TCOD)
event_handler = EventHandler()
#entities
player = Entity(screen_width // 2, screen_height // 2, "@", (255, 255, 255))
shopkeeper = Entity(screen_width // 2 - 5, screen_height // 2, "@", (255, 255, 0))
entities = {player, shopkeeper}
engine = Engine(entities, event_handler, player)
with tcod.context.new_terminal(
screen_width,
screen_height,
tileset=tileset,
title="Stepwise Tutorial",
vsync=True,
) as context:
root_console = tcod.console.Console(screen_width, screen_height, order="F")
while True:
engine.render(console = root_console, context = context)
events = tcod.event.wait()
engine.handle_events(events)
if __name__ == "__main__":
main()