From 0dc8d4532b03511b33cae491f6e7996110c558eb Mon Sep 17 00:00:00 2001 From: Ivan Vashchaev Date: Wed, 20 May 2015 14:15:56 +0300 Subject: [PATCH] Control snake by 'hjkl' --- snake/config.py | 10 +++++----- snake/controls.py | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/snake/config.py b/snake/config.py index 0e214e3..66daf9c 100644 --- a/snake/config.py +++ b/snake/config.py @@ -2,11 +2,11 @@ frame_len = .1 keys = { - 'DOWN': 0x42, - 'LEFT': 0x44, - 'RIGHT': 0x43, - 'UP': 0x41, - 'Q': 0x71, + 'DOWN': (0x42, 0x6a, 0x4a), + 'LEFT': (0x44, 0x68, 0x48), + 'RIGHT': (0x43, 0x6c, 0x4c), + 'UP': (0x41, 0x6b, 0x4b), + 'Q': (0x71, 0x51), 'ENTER': 0x0a, } diff --git a/snake/controls.py b/snake/controls.py index a5ba89c..91a52ab 100644 --- a/snake/controls.py +++ b/snake/controls.py @@ -10,31 +10,31 @@ def update(): key = graphics.screen.getch() if key > 0: - if key == keys['DOWN']: + if key in keys['DOWN']: if game.direction[1] == -1: return game.direction = (0, 1) - elif key == keys['LEFT']: + elif key in keys['LEFT']: if game.direction[0] == 1: return game.direction = (-1, 0) - elif key == keys['RIGHT']: + elif key in keys['RIGHT']: if game.direction[0] == -1: return game.direction = (1, 0) - elif key == keys['UP']: + elif key in keys['UP']: if game.direction[1] == 1: return game.direction = (0, -1) - elif key == keys['Q']: + elif key in keys['Q']: __main__.exit() exit()