diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7b62f12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +.vscode \ No newline at end of file diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..d7cacfc --- /dev/null +++ b/Pipfile @@ -0,0 +1,21 @@ +[[source]] + +url = "https://github.com/trprado/roguelike_tutorial_revised_tdl" +verify_ssl = true +name = "roguelike tutorial revised with tdl" + + +[dev-packages] + +pylint = "*" + + +[packages] + +tdl = "*" + + + +[requires] + +python_version = "3.6" diff --git a/engine.py b/engine.py index b78f724..1dfd160 100644 --- a/engine.py +++ b/engine.py @@ -30,6 +30,8 @@ def main(): make_map(game_map) while not tdl.event.is_window_closed(): + user_input = None + render_all(con, entities, game_map, root_console, screen_width, screen_height, colors) tdl.flush() @@ -39,8 +41,8 @@ def main(): if event.type == 'KEYDOWN': user_input = event break - else: - user_input = None + else: + user_input = None if not user_input: continue @@ -53,14 +55,13 @@ def main(): if move: dx, dy = move - if game_map.walkable[player.x + dx, player.y + dy]: player.move(dx, dy) - - if exit: - return True - - if fullscreen: + elif exit: + if tdl.get_fullscreen(): + tdl.set_fullscreen(False) + break + elif fullscreen: tdl.set_fullscreen(not tdl.get_fullscreen()) diff --git a/input_handlers.py b/input_handlers.py index 4534d09..f247724 100644 --- a/input_handlers.py +++ b/input_handlers.py @@ -9,7 +9,7 @@ def handle_keys(user_input): elif user_input.key == 'RIGHT': return {'move': (1, 0)} - if user_input.key == 'ENTER' and user_input.alt: + if user_input.key == 'ENTER' and user_input.control: # Alt+Enter: toggle full screen return {'fullscreen': True} elif user_input.key == 'ESCAPE':