2022-01-02 15:23:25 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import tcod
|
2022-01-02 17:19:43 +00:00
|
|
|
import copy
|
|
|
|
import entity_factories
|
2022-01-02 15:23:25 +00:00
|
|
|
|
|
|
|
from engine import Engine
|
|
|
|
from input_handlers import EventHandler
|
|
|
|
from procgen import generate_dungeon
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
screen_width = 80
|
|
|
|
screen_height = 50
|
|
|
|
|
|
|
|
map_width = 80
|
|
|
|
map_height = 45
|
|
|
|
|
|
|
|
room_max_size = 10
|
|
|
|
room_min_size = 6
|
|
|
|
max_rooms = 30
|
|
|
|
|
2022-01-02 17:19:43 +00:00
|
|
|
max_monsters_per_room = 2
|
|
|
|
|
2022-01-02 15:23:25 +00:00
|
|
|
tileset = tcod.tileset.load_tilesheet(
|
|
|
|
"dejavu10x10_gs_tc.png", 32, 8, tcod.tileset.CHARMAP_TCOD
|
|
|
|
)
|
|
|
|
|
2022-01-02 17:19:43 +00:00
|
|
|
player = copy.deepcopy(entity_factories.player)
|
2022-01-02 17:50:33 +00:00
|
|
|
engine = Engine(player=player)
|
2022-01-02 15:23:25 +00:00
|
|
|
|
2022-01-02 17:50:33 +00:00
|
|
|
engine.game_map = generate_dungeon(
|
2022-01-02 15:23:25 +00:00
|
|
|
max_rooms=max_rooms,
|
|
|
|
room_min_size=room_min_size,
|
|
|
|
room_max_size=room_max_size,
|
|
|
|
map_width=map_width,
|
|
|
|
map_height=map_height,
|
2022-01-02 17:19:43 +00:00
|
|
|
max_monsters_per_room=max_monsters_per_room,
|
2022-01-02 17:50:33 +00:00
|
|
|
engine=engine,
|
2022-01-02 15:23:25 +00:00
|
|
|
)
|
2022-01-02 17:50:33 +00:00
|
|
|
engine.update_fov()
|
2022-01-02 15:23:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
with tcod.context.new_terminal(
|
2022-01-02 17:19:43 +00:00
|
|
|
screen_width,
|
|
|
|
screen_height,
|
|
|
|
tileset=tileset,
|
|
|
|
title="Yet Another Roguelike Tutorial",
|
|
|
|
vsync=True,
|
2022-01-02 15:23:25 +00:00
|
|
|
) as context:
|
|
|
|
root_console = tcod.Console(screen_width, screen_height, order="F")
|
|
|
|
while True:
|
|
|
|
engine.render(console=root_console, context=context)
|
2022-01-02 17:50:33 +00:00
|
|
|
engine.event_handler.handle_events()
|
2022-01-02 15:23:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|