Configure keys

Started by Nick Dangerous, Sat 23/10/2004 15:47:49

Previous topic - Next topic

Nick Dangerous

Found a lot of threads bout keyboard-movement, but none bout this:
Is there a way to enable the player to configure the keys?
I'm thinking of a lot of if's but I'm afraid to start to script it this way, becaus I know that I probably never gonna finish it. Can you stay the keycodes of the keys pressed in variables and then check for these?

Scorpiorus

#1
Yep, you can store keycode values in variables and then compare to that variables rather than constant values:

int keycode_for_up = <default value>;
int keycode_for_down = <default value>;
int keycode_for_left = <default value>;
int keycode_for_right = <default value>;


if (IsKeyPressed(keycode_for_up)) {<MOVE UP>}
if (IsKeyPressed(keycode_for_down)) {<MOVE DOWN>}
if (IsKeyPressed(keycode_for_left)) {<MOVE LEFT>}
if (IsKeyPressed(keycode_for_right)) {<MOVE RIGHT>}

You can then make a dialog and when the player customizes a certain key you change the appropriate keycode_for_XXX variable.

SMF spam blocked by CleanTalk