projects
/
erdslangetjie.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Redo keyboard navigation code to support WASD as well
[erdslangetjie.git]
/
erdslangetjie
/
__main__.py
diff --git
a/erdslangetjie/__main__.py
b/erdslangetjie/__main__.py
index 9a609c610d75dc7e5c96edeb41fe27d2d0c26af8..71ef53b405cc46e9c6f5a8780109e6eaeac8abda 100644
(file)
--- a/
erdslangetjie/__main__.py
+++ b/
erdslangetjie/__main__.py
@@
-1,6
+1,4
@@
-import pygame
-
-from erdslangetjie.constants import TILE_SIZE
+from erdslangetjie.constants import TILE_SIZE, LEFT, RIGHT, UP, DOWN
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.app import App
from kivy.uix.widget import Widget
@@
-164,15
+162,15
@@
class GameWindow(RelativeLayout):
self.keyboard.unbind(on_key_down=self._on_key_down)
def _on_key_down(self, keyboard, keycode, text, modifiers):
self.keyboard.unbind(on_key_down=self._on_key_down)
def _on_key_down(self, keyboard, keycode, text, modifiers):
- # FIXME - likely portablity issues
direction = None
direction = None
- if keycode[0] == pygame.K_UP:
+ letter = keycode[1].lower()
+ if letter in UP:
direction = (0, 1)
direction = (0, 1)
- elif
keycode[0] == pygame.K_
DOWN:
+ elif
letter in
DOWN:
direction = (0, -1)
direction = (0, -1)
- elif
keycode[0] == pygame.K_
LEFT:
+ elif
letter in
LEFT:
direction = (-1, 0)
direction = (-1, 0)
- elif
keycode[0] == pygame.K_
RIGHT:
+ elif
letter in
RIGHT:
direction = (1, 0)
if direction:
self.do_move(direction)
direction = (1, 0)
if direction:
self.do_move(direction)