I've been using this tutorial to create a game loop.
In the section marked "FPS dependent on Constant Game Speed" there is some example code that includes a Sleep command
I googled the equivalent in java and found it is
Thread.sleep();
but it returns an error in eclipse
Unhandled exception type InterruptedException
What on earth does that mean.
And also I was wondering what the
update_game();
display_game();
methods may contain in an opengl-es game (ie: where is the renderer updated and what sort of things go on in display_game();
I am currently using a system that uses the GLSurfaceView and GLSurfaceRenderer features
Here is my adaptation of the code in the tutorial
public Input(Context context){
super(context);
glSurfaceRenderer = new GLSurfaceRenderer();
checkcollisions = new Collisions();
while (gameisrunning) {
setRenderer(glSurfaceRenderer);
nextGameTick += skipTicks;
sleepTime = nextGameTick - SystemClock.uptimeMillis();
if(sleepTime >= 0) {
Thread.sleep(sleepTime);
}else{
//S*** we're behind
}
}
This is called in my GLSurfaceView although I'm not sure whether this is the right place to implement this.