1
0
python-roguelike/main.py
2022-01-06 11:28:03 -05:00

46 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python3
import tcod
from engine import Engine
from entity import Entity
from input_handlers import EventHandler
def main() -> None:
screen_width = 80
screen_height = 50
tileset = tcod.tileset.load_tilesheet(
"dejavu10x10_gs_tc.png",
32,
8,
tcod.tileset.CHARMAP_TCOD
)
event_handler = EventHandler()
player = Entity(int(screen_width / 2), int(screen_height/ 2), "@", (255, 255, 255))
npc = Entity(int(screen_width / 2 - 5), int(screen_height / 2), "@", (255, 255, 0))
entities = {npc, player}
engine = Engine(entities, event_handler, player)
with tcod.context.new_terminal(
screen_width,
screen_height,
tileset=tileset,
title="Yet Another Roguelike Tutorial",
vsync=True,
) as context:
root_console = tcod.Console(screen_width, screen_height, order="F")
while True:
engine.render(root_console, context)
events = tcod.event.wait()
engine.handle_events(events)
if __name__ == "__main__":
main()