Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actual~Helgon

Posted 11 December 2012 - 06:40 PM

Do not use switch then.

public void keyPressed(KeyEvent e){

   if(e.getKeyCode() == KeyEvent.VK_UP){
	 up = true;
   }

   if(e.getKeyCode() == KeyEvent.VK_DOWN){
	 down = true;
   }
}

and then in the game loop just check

if(up){
   player.moveUp();
}

if(down){
   player.moveDown();
}

Should work.. that's the way i done it in some sidescrollers in java

Regards

#1~Helgon

Posted 11 December 2012 - 06:39 PM

Do not use switch then.

public void keyPressed(KeyEvent e){

if(e.getKeyCode() == KeyEvent.VK_UP){
	 up = true;
}
}

and then in the game loop just check

if(up){
player.moveUp();
}

Should work.. that's the way i done it in some sidescrollers in java

Regards

PARTNERS