Files
RLD_CT/main.py
2021-05-26 16:36:59 -04:00

57 lines
1.3 KiB
Python

import tcod
from engine import Engine
from entity import Entity
from game_map import GameMap
from input_handlers import EventHandler
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
colors = {
'dark_wall': tcod.Color(0, 0, 100),
'dark_ground': tcod.Color(50, 50, 150)
}
tileset = tcod.tileset.load_tilesheet(
"arial10x10.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), int(screen_height/2), '@', (255, 255, 0))
entities = {npc, player}
game_map = GameMap(map_width, map_height)
engine = Engine(entities=entities, event_handler=event_handler, game_map=game_map, player=player)
with tcod.context.new_terminal(
screen_width,
screen_height,
tileset=tileset,
title='Roguelike Tutorial',
vsync=True,
) as context:
root_console = tcod.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()