PDA

View Full Version : Specific question about movement



polyp
January 28th, 2009, 05:43 PM
Hello everyone,


I'm currently trying to make a very simple game where movement in one direction is done by pressing 2 keys alternately...

for example to move to the left, the user has to press A, S, A, S ... repeatedly (kind of like twiddling his fingers

and to move to the right, the user would have to press K, L, K, L repeatedly...


can anyone give me some insight on how this could be done?



thanks in advance

cbeech
January 28th, 2009, 05:54 PM
you would need to set up two boolean variables for each pair of buttons, then alternate their state when the button is pressed. in your handler you would use a condition to check if the button's variable is 'true' - if so, flip-flop the variables for the pair and then move the object slightly. so now if the user presses the same button again the condition will fail and not move the object nor swap the variable values.

polyp
January 28th, 2009, 05:55 PM
ah okay

i'm so new to this, that it BARELY makes sense to me but i think i understand what you're getting at!

thanks =)

cbeech
January 28th, 2009, 06:27 PM
you're welcome :) here's a quick example:

polyp
January 28th, 2009, 11:17 PM
wow that's exactly what i wanted

thanks a ton. I'll "study" that thing a bit to make sure i full understand it.