On Mon, May 11, 2009 at 9:31 PM, Fawkes <fawkesga...@gmail.com> wrote:
> 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 > That is fine to hold default keybinding, but into the game loop is more usefull the inverse dictionay: when you receive a key from pygame, you get the command by indexing the dict with the key. -- claxo