Hi. I have a little problem about game loop.
I’m designing a simple game-loop for a puzzle game. I’m used to do it in C++. A simple while, and some flags to detect cell colision, key imput, and so.
But I’m trying to do it in a java stand-alone, and I wanna do it “by the java way”. And that means, handle the keywoard events and perhaps any other event in the game (time control, collision of blocks, and so).
Can you help me a little? The run method i have is very simple:
public void run()
{
while(gamimg)
{
wait(500);
}
}
How can I detect the keys? I have a simple keyDown event but, when i’m debugging, I never enter.
public boolean keyDown(Event evt, int key){
return false;
}