Refactor event handling into EventHandler
Move all the event handling code from Engine to EventHandler. EventHandler has a reference to Engine and can deal with entities from its methods. Refactor Action to take an optional Entity in its initializer. Some actions don't require an Entity, but many do/will.
This commit is contained in:
parent
d75c9faea3
commit
8b3c0137a5
4 changed files with 107 additions and 82 deletions
|
@ -64,9 +64,9 @@ def main(argv):
|
|||
tileset = tcod.tileset.load_tilesheet(font, 16, 16, tcod.tileset.CHARMAP_CP437)
|
||||
console = tcod.Console(CONSOLE_WIDTH, CONSOLE_HEIGHT, order='F')
|
||||
|
||||
event_handler = EventHandler()
|
||||
configuration = Configuration(map_size=Size(MAP_WIDTH, MAP_HEIGHT))
|
||||
engine = Engine(event_handler, configuration)
|
||||
engine = Engine(configuration)
|
||||
event_handler = EventHandler(engine)
|
||||
|
||||
with tcod.context.new(columns=console.width, rows=console.height, tileset=tileset) as context:
|
||||
while True:
|
||||
|
@ -74,8 +74,7 @@ def main(argv):
|
|||
engine.print_to_console(console)
|
||||
context.present(console)
|
||||
|
||||
for event in tcod.event.wait():
|
||||
engine.handle_event(event)
|
||||
event_handler.wait_for_events()
|
||||
|
||||
def run_until_exit():
|
||||
'''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue