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 05a25af..0706622 100644 --- a/engine.py +++ b/engine.py @@ -16,6 +16,8 @@ def main(): con = tdl.Console(screen_width, screen_height) while not tdl.event.is_window_closed(): + user_input = None + con.draw_char(player_x, player_y, '@', bg=None, fg=(255, 255, 255)) root_console.blit(con, 0, 0, screen_width, screen_height, 0, 0) tdl.flush() @@ -26,8 +28,8 @@ def main(): if event.type == 'KEYDOWN': user_input = event break - else: - user_input = None + else: + user_input = None if not user_input: continue @@ -42,11 +44,12 @@ def main(): dx, dy = move player_x += dx player_y += dy + elif exit: + if tdl.get_fullscreen(): + tdl.set_fullscreen(False) + break - if exit: - return True - - if fullscreen: + 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':