How might I do this in a keylistener properly to use thread.sleep if the while condition is based on the key pressed (spacebar)?
//PROBLEM HERE - THIS IS IN A KEY LISTENER
while(e.getKeyCode()!=32)
{
try
{
//Set players last square to red/blue
gridArray[player1.getY()][player1.getX()].setIcon(redImg);
gridArray[player2.getY()][player2.getX()].setIcon(blueImg);
player1.update(player1.getDirection());
player2.update(player2.getDirection());
Thread.sleep(500);
}
catch (InterruptedException ex)
{
System.out.println("Timer Error");//just break through
}
}