Using Events (game loop)

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;
}

For starters, I think you would want to read some basic tutorials at Sun.

Event listener basics:
http://java.sun.com/docs/books/tutorial/uiswing/events/index.html

Games and events:
http://www.javacooperation.gmxhome.de/TutorialStartEng.html

To use key events and mouse events you need a window.
If you don’t like it then you can use LWJGL, jME or Xith3D.
Those 3 require knowledge in OpenGL though.

Might I add, your post is in the wrong forum. :wink:

you could also try jinput.