2022-01-06 11:09:43 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import tcod
|
|
|
|
|
2022-01-06 11:28:03 -05:00
|
|
|
from engine import Engine
|
2022-01-06 11:19:56 -05:00
|
|
|
from entity import Entity
|
2022-01-06 11:09:43 -05:00
|
|
|
from input_handlers import EventHandler
|
2022-01-06 13:27:15 -05:00
|
|
|
from procgen import generate_dungeon
|
2022-01-06 11:09:43 -05:00
|
|
|
|
|
|
|
|
|
|
|
def main() -> None:
|
|
|
|
screen_width = 80
|
|
|
|
screen_height = 50
|
|
|
|
|
2022-01-06 11:56:08 -05:00
|
|
|
map_width = 80
|
|
|
|
map_height = 50
|
|
|
|
|
2022-01-06 11:09:43 -05:00
|
|
|
tileset = tcod.tileset.load_tilesheet(
|
|
|
|
"dejavu10x10_gs_tc.png",
|
|
|
|
32,
|
|
|
|
8,
|
|
|
|
tcod.tileset.CHARMAP_TCOD
|
|
|
|
)
|
|
|
|
|
|
|
|
event_handler = EventHandler()
|
|
|
|
|
2022-01-06 13:27:15 -05:00
|
|
|
player = Entity(int(screen_width / 2), int(screen_height / 2), "@", (255, 255, 255))
|
2022-01-06 11:19:56 -05:00
|
|
|
npc = Entity(int(screen_width / 2 - 5), int(screen_height / 2), "@", (255, 255, 0))
|
|
|
|
entities = {npc, player}
|
|
|
|
|
2022-01-06 13:27:15 -05:00
|
|
|
game_map = generate_dungeon(map_width, map_height)
|
2022-01-06 11:56:08 -05:00
|
|
|
|
|
|
|
engine = Engine(entities, event_handler, game_map, player)
|
2022-01-06 11:28:03 -05:00
|
|
|
|
2022-01-06 11:09:43 -05:00
|
|
|
with tcod.context.new_terminal(
|
2022-01-06 13:27:15 -05:00
|
|
|
screen_width,
|
|
|
|
screen_height,
|
|
|
|
tileset=tileset,
|
|
|
|
title="Yet Another Roguelike Tutorial",
|
|
|
|
vsync=True,
|
2022-01-06 11:09:43 -05:00
|
|
|
) as context:
|
|
|
|
root_console = tcod.Console(screen_width, screen_height, order="F")
|
|
|
|
while True:
|
2022-01-06 11:28:03 -05:00
|
|
|
engine.render(root_console, context)
|
2022-01-06 11:09:43 -05:00
|
|
|
|
2022-01-06 11:28:03 -05:00
|
|
|
events = tcod.event.wait()
|
2022-01-06 11:09:43 -05:00
|
|
|
|
2022-01-06 11:28:03 -05:00
|
|
|
engine.handle_events(events)
|
2022-01-06 11:09:43 -05:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|