Stepwise/source/main.py

50 lines
1.3 KiB
Python
Executable File

#!./bin/python
import tcod
from engine import Engine
from entity import Entity
from procgen import generate_dungeon
from event_handler import EventHandler
def main() -> None:
#Initial values
screen_width = 80
screen_height = 50
map_width = 80
map_height = 45
room_size_max = 10
room_size_min = 6
room_count_max = 30
tileset = tcod.tileset.load_tilesheet("assets/dejavu10x10_gs_tc.png", 32, 8, tcod.tileset.CHARMAP_TCOD)
#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}
game_map = generate_dungeon(room_count_max=room_count_max, room_size_min=room_size_min, room_size_max=room_size_max, map_width=map_width, map_height=map_height, player=player)
event_handler = EventHandler()
engine = Engine(entities, event_handler, game_map, 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()