PDA

View Full Version : Multiple Keys



amps7
April 1st, 2005, 09:36 AM
:ponder: Hey,im half way through my hero's code for my game but i need to know what the code is for using multiple keys.Once the down key is pressed he will duck so now i want him to move right or left depending on the key pressed.I was aware that you use "&" but this dosent seem to work.

Hexagram
April 1st, 2005, 10:48 AM
I'm having a similar problem dude. But i think in you case you should use a double ampersand like &&.

example
if(((Key.isDown(Key.Down) )&& (Key.isDown(Key.Right))){
//execute movement
}

amps7
April 2nd, 2005, 05:46 PM
k,thanx il give it a shot :)

nathan99
April 4th, 2005, 09:46 PM
hey guys,this is the code you use



if (Key.isDown(Key.DOWN) && Key.isDown(Key.LEFT)) {
//action
}
to edit it u jus add in another "&& Key.isDown(Key.CONTROL)", before the last bracket, heres an example;



if (Key.isDown(Key.DOWN) && Key.isDown(Key.CONTROL) && Key.isDown(Key.SPACE) && Key.isDown(Key.ALT)) {
//action
}

this checks that the down, control, space and alt buttons are presseed.