-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
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
- if keycode[0] == pygame.K_UP:
+ letter = keycode[1].lower()
+ if letter in UP:
direction = (0, 1)
- elif keycode[0] == pygame.K_DOWN:
+ elif letter in DOWN:
direction = (0, -1)
- elif keycode[0] == pygame.K_LEFT:
+ elif letter in LEFT:
direction = (-1, 0)
- elif keycode[0] == pygame.K_RIGHT:
+ elif letter in RIGHT:
direction = (1, 0)
if direction:
self.do_move(direction)