From 615d4ac5de0aed3f5ff4a07742ba2f42ea4ed7be Mon Sep 17 00:00:00 2001 From: Thiago Prado Date: Thu, 22 Feb 2018 15:22:41 -0300 Subject: [PATCH 1/4] Turn `user_input` in a local variable and improve output when in fullscreen, to not break screen size of system. --- .vscode/settings.json | 3 +++ Pipfile | 21 +++++++++++++++++++++ __pycache__/input_handlers.cpython-36.pyc | Bin 0 -> 542 bytes engine.py | 6 +++++- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json create mode 100644 Pipfile create mode 100644 __pycache__/input_handlers.cpython-36.pyc diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1bad8ff --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/home/trprado/.virtualenvs/roguelike-UEyMhNB9/bin/python3.6" +} \ 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/__pycache__/input_handlers.cpython-36.pyc b/__pycache__/input_handlers.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ea024de1b681dc4c25160cef735764c0deb28ae4 GIT binary patch literal 542 zcmYk2y-ve05XT)SZA04fQ8s3lEM!1pLI~6bS_y@!4MNJ2R<)s_ZX7uuq7owm8_&Tj zd1dM=u)sN0qn>ns`+j#i-}$`Vwm!|Tz{LptpdEu4U4y4B5Q2#IfdWME7}@$v1Efry zI(Qd6EkNGUD^xD9=nzcyBW=7PH6W)z4k}UyaslM1A`KvYAf1YsKqk;p6BDvWtco{* z3)0$<2*E_hUVtBm(pd6>u3-$cR+9xr@8QXl#=U#%%i3sg*Y|^(>-p|TTF*IS=}b@> z`$63ucW;KSH0WEDt^dGmEY$kK1liuzo?D=JSpmtCt7;odeL+{UG2?M2II}fry~&7Azl!by8QA$ae5$2R# z!ud2NjEeLuS;^)m2;tFG?VFx}AZ%%-w&VB^LyS#b>_gVGwel>7*^xHnq Date: Thu, 22 Feb 2018 15:26:25 -0300 Subject: [PATCH 2/4] add gitignore --- .gitignore | 2 ++ .vscode/settings.json | 3 --- __pycache__/input_handlers.cpython-36.pyc | Bin 542 -> 0 bytes 3 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 .gitignore delete mode 100644 .vscode/settings.json delete mode 100644 __pycache__/input_handlers.cpython-36.pyc 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/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 1bad8ff..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "python.pythonPath": "/home/trprado/.virtualenvs/roguelike-UEyMhNB9/bin/python3.6" -} \ No newline at end of file diff --git a/__pycache__/input_handlers.cpython-36.pyc b/__pycache__/input_handlers.cpython-36.pyc deleted file mode 100644 index ea024de1b681dc4c25160cef735764c0deb28ae4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 542 zcmYk2y-ve05XT)SZA04fQ8s3lEM!1pLI~6bS_y@!4MNJ2R<)s_ZX7uuq7owm8_&Tj zd1dM=u)sN0qn>ns`+j#i-}$`Vwm!|Tz{LptpdEu4U4y4B5Q2#IfdWME7}@$v1Efry zI(Qd6EkNGUD^xD9=nzcyBW=7PH6W)z4k}UyaslM1A`KvYAf1YsKqk;p6BDvWtco{* z3)0$<2*E_hUVtBm(pd6>u3-$cR+9xr@8QXl#=U#%%i3sg*Y|^(>-p|TTF*IS=}b@> z`$63ucW;KSH0WEDt^dGmEY$kK1liuzo?D=JSpmtCt7;odeL+{UG2?M2II}fry~&7Azl!by8QA$ae5$2R# z!ud2NjEeLuS;^)m2;tFG?VFx}AZ%%-w&VB^LyS#b>_gVGwel>7*^xHnq Date: Thu, 22 Feb 2018 15:33:36 -0300 Subject: [PATCH 3/4] The shortcut changed to the modifier key of some wm like i3 works correctly for full screen. --- input_handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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': From 4e66fad33b8fe530a84e73be659de901074462c8 Mon Sep 17 00:00:00 2001 From: Thiago Prado Date: Thu, 22 Feb 2018 16:36:32 -0300 Subject: [PATCH 4/4] improve and correct if,elif and else statements --- engine.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/engine.py b/engine.py index b0a3337..0706622 100644 --- a/engine.py +++ b/engine.py @@ -28,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 @@ -44,13 +44,12 @@ def main(): dx, dy = move player_x += dx player_y += dy - - if exit: + elif exit: if tdl.get_fullscreen(): tdl.set_fullscreen(False) break - if fullscreen: + elif fullscreen: tdl.set_fullscreen(not tdl.get_fullscreen())