[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] [Pygame] Key Configuration



Hello again

I was wondering what would be the best way to do a key configuration
for my game? One of the comments from our recent release (
http://pygame.org/project/1106/ ) was that we ought to have the
controls configurable by the player for instance if they have a non
QWERTY keyboard. Right now all the controls are hard coded (e.g. the
game looks to see if Z is pressed, do something). I was thinking of
using a dictionary like the following.

controls{
"confirm":K_z,
"cancel":K_x
"prev_ally":K_a,
"next_ally":K_s,
"prev_enemy":K_q,
"next_enemy":"K_w}

The values within the dictionary would be changeable by the player
within the game. Is this a good way to go about doing this?

Thanks in advance
-Fawkes