Page 3 of 3

Re: User Define keys in a game

Posted: Mon Dec 14, 2009 7:01 am
by Robin
Why even use strings anyway? You could have replaced all those occurrences of "P1Left" etc. with P1Left etc., as you use those strings only as some sort of "references" to functions, for which you can use the function's name as well.

Re: User Define keys in a game

Posted: Mon Dec 14, 2009 2:54 pm
by tido170
it's because the user starts by selecting a player (P1 to P4) and an action (Right, Left, etc). The info is stored in the string and then the key he presses is binded to this.

Re: User Define keys in a game

Posted: Mon Dec 14, 2009 4:11 pm
by Robin
tido170 wrote:it's because the user starts by selecting a player (P1 to P4) and an action (Right, Left, etc). The info is stored in the string and then the key he presses is binded to this.
I think it would then make sense to have a keyfuncs table with this layout:

Code: Select all

keyfuncs = {
    P1 = {
        Right = P1Right,
        Left = P1Left,
        (...)
        },
    P2 = {
        (...)
        },
    (...)
    }
This might be useful if you decide to change some function names.

... but on the other hand, this might not make any sense. Feel free to ignore me if that's the case. ;)