Hello Forum!
Im having issues!
In my game, the player controls a snake, but i cant make it move right and up at the same time, or down and left, etc;;;
It can only go one direction at a time…
I researched a lot, but couldnt make it work.
@Override
public void keyPressed(KeyEvent e) {
boolean setaPraCima = false;
boolean setaPraBaixo = false;
boolean setaPraDireita = false;
boolean setaPraEsquerda = false;
//System.out.println("Pressed : Key Code :: " + e.getKeyCode() + " == " + e.getKeyChar());
if (e.getKeyCode() == 38) { // Seta pra cima
setaPraCima = true;
gameUpdate.moveSnakeUp();
} else
if (e.getKeyCode() == 40)
{
setaPraBaixo = true;
gameUpdate.moveSnakeDown();
}else
if(e.getKeyCode() == 39)
{
setaPraDireita = true;
gameUpdate.moveSnakeRight();
} else
if(e.getKeyCode() == 37)
{
setaPraEsquerda = true;
gameUpdate.moveSnakeLeft();
}
gameUpdate.GameUpdate();
}