51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
import tcod
|
|
|
|
from engine import Engine
|
|
from entity import Entity
|
|
from input_handlers import EventHandler
|
|
|
|
|
|
|
|
def main():
|
|
screen_width = 80
|
|
screen_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)
|
|
}
|
|
|
|
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}
|
|
|
|
engine = Engine(entities=entities, event_handler=event_handler, 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() |