We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Keyboard input delay
Page Index Toggle Pages: 1
Keyboard input delay (Read 665 times)
Keyboard input delay
Jul 11th, 2009, 2:05am
 
Hello everyone, i'm Sengir and i'm new of this forum...I'm going to ask you something about processing...I'm programming an old style videogame, a bidimensional ships shooter, but there is a problem. When I move the ship from left to right or from down to up, pressing two buttons in the same moment, the ship stops itself for a while, and then it continues to move...for movements I use this code:

Code:
if (keyPressed)
   {

     if(keyCode==LEFT)
       foo.moveLeft();
     else if(keyCode==RIGHT)
       foo.moveRight();
     else if(keyCode==UP)
       foo.moveUp();
     else if(keyCode==DOWN)
       foo.moveDown();

   }


where for example foo.moveDown(); is:

Code:
 void moveDown()
 {
   
     ypos +=5;  

 }


there's a way to eliminate that horrible delay from a change direction to another? if someone need the entire code ask me...thank you!

Re: Keyboard input delay
Reply #1 - Jul 11th, 2009, 2:14am
 
There are several examples on the forum to handle multiple key input, for example at http://processing.org/discourse/yabb2/num_1243835922.html#2 (blindfish's code).
Re: Keyboard input delay
Reply #2 - Jul 13th, 2009, 12:03am
 
Thank you very much!!!! It helps me a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Page Index Toggle Pages: 1