i’ve tried using GAGE as many people have pointed it out.
the fps seems not to “explode” again.
however there are still problems.
the fps will never get above 50 fps even though i cap the redraw 100 fps.
another thing is that as time goes by, the frame rate seems to decrease until 20-30 fps and never increases again.
this is very frustating.
my code is just a simple one.
while(run)
{
redraw();
simulatorCalculation();
}
i implement the double buffering myself. is it possible that this is the source of the problem? also i use 1020x750 window size (i’m not using fullscreen), plus i also render the background plus the object (so far only 1 object) every time i redraw.
what is the possible cause of the problem?
my code is quite big since i have many classes around.
if you want to inspect it, maybe i could send to u the zip files.
thanks for your help
the main:
public void runSimulator()
{
if(VISUAL_ON && FPS_ON)
{
at = new AdvancedTimer();
tick = 0;
at.start();
ticksPerFrame = AdvancedTimer.getTicksPerSecond() / DESIRED_FPS;
lastTime = System.currentTimeMillis();
frameNo = 0;
//startTime = System.currentTimeMillis();
}
while(run)
{
if(VISUAL_ON && FPS_ON)
{
//elapsedTime = System.currentTimeMillis();
if(System.currentTimeMillis() - lastTime > 1000)
{
lastTime += 1000;
displayFrameRate(frameNo);
frameNo = 0;
}
frameNo++;
}
if(VISUAL_ON)
{
repaint();
//pause(1);
}
// Update the objects position for the next 1 second (the simulation time cycle).
updateObjectsPosition(1);
fieldCollisions();
if(VISUAL_ON && FPS_ON)
{
at.sleepUntil(tick + ticksPerFrame);
tick += ticksPerFrame;
}
}
}