Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Arrows and Dvorak #2

Closed
wants to merge 1 commit into from

1 participant

@Fuuzetsu

Doing a whole config screen turned out to be an overkill just for 4 key remaps. You should really plan shit out better before you sit down to code.

@Fuuzetsu

old

@Fuuzetsu Fuuzetsu closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 6, 2012
  1. @Fuuzetsu
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 4 deletions.
  1. +10 −4 game.py
View
14 game.py
@@ -230,13 +230,19 @@ def _axis_move(self, axis, pos):
elif axis == "y": self.y += pos
def move(self, dt, keys):
- if pyglet.window.key.W in keys:
+ k = pyglet.window.key
+ up = [k.W, k.COMMA, k.UP]
+ down = [k.S, k.O, k.DOWN]
+ left = [k.A, k.LEFT]
+ right = [k.D, k.E, k.RIGHT]
+ anyIn = lambda l, m: reduce(lambda a, b: a or b, [x in m for x in l])
+ if anyIn(up, keys):
self.axis_move(dt, "y", self.speed)
- if pyglet.window.key.S in keys:
+ if anyIn(down, keys):
self.axis_move(dt, "y", -1 * self.speed)
- if pyglet.window.key.D in keys:
+ if anyIn(right, keys):
self.axis_move(dt, "x", self.speed)
- if pyglet.window.key.A in keys:
+ if anyIn(left, keys):
self.axis_move(dt, "x", -1 * self.speed)
class Present(pyglet.sprite.Sprite, Collide):
Something went wrong with that request. Please try again.