Files
RLD_CT/engine.py
2021-05-26 13:06:40 -04:00

66 lines
1.7 KiB
Python

import tcod
from entity import Entity
from render_functions import *
from game_map import *
from input_handlers import EventHandler
from actions import EscapeAction, MovementAction
def main():
screen_width = 80
screen_height = 50
map_width = 80
map_height = 50
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)
}
# player = Entity(int(screen_width/2), int(screen_height/2), '@', tcod.white)
# npc = Entity(int(screen_width/2), int(screen_height/2), '@', tcod.yellow)
# entities = [npc, player]
player_x = int(screen_width/2)
player_y = int(screen_width/2)
tileset = tcod.tileset.load_tilesheet(
"arial10x10.png", 32,8, tcod.tileset.CHARMAP_TCOD
)
event_handler = EventHandler()
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:
root_console.print(x=player_x, y=player_y, string="@")
context.present(root_console)
root_console.clear()
for event in tcod.event.wait():
action = event_handler.dispatch(event)
if action is None:
continue
if isinstance(action, MovementAction):
player_x += action.dx
player_y += action.dy
elif isinstance(action, EscapeAction):
raise SystemExit()
if __name__ == '__main__':
main()