Need help with Keydown Control

Posted:
Thu Jun 03, 2010 7:06 am
by sillydraco
I have a quick question, i added a climbing feature to my game. i made it so that if my character was between the edges of a vine wall (i made three actors, the left border, middle vine wall, and the right border) and whenever you keydown "up" he will climb. everything works fine until you keydown two arrowkeys at the same time. then things fall out of whack (namely the character falls off the wall) how do i keep the player from messing things up by keydowning too many arrowkeys? i tried using variables (up down left and right) and setting it so that whenever one key is pressed (if the variable for that arrow == 1) it sets the other variables to 0. then on the keyup it would set all of them back to 1. it still doesnt work though

for some reason, my drag and drop upload box doesnt work
http://scalesnfuzz.com/Levels.zip
Re: Need help with Keydown Control

Posted:
Thu Jun 10, 2010 4:26 am
by Chai
Actually if you press two key at the same time, Those key will work at the same time.
So the code will minus itself.
example:
Key Up : y -= 5;
Key Down : y += 5;
when you press both of it Y will be 0;
Normally when People play the game.
It is really rarely to find a player who press opposite direction button at the same time.
So I think you no need to worry about it.
Re: Need help with Keydown Control

Posted:
Fri Jun 11, 2010 4:20 pm
by DST
Good point, on a controller, you can't hit left and right at the same time.
But if you want to keep only one key active, just use a global variable, and assign each key a number. That way, you don't have to reset the others, the global variable will always hold the value of the last key pressed.
Re: Need help with Keydown Control

Posted:
Tue Jul 06, 2010 6:06 pm
by sillydraco
huh guess i shoulda thought of that x3 i mainly didnt want people pressing up and left at the same time, it confuses the code and makes you fall off the wall x3