How do i call for my paint method to draw everything inside it withing my thick method that runs 60 times per second.
this is the fps calculation :
int FRAMES_PER_SECOND = 60;
long maxWorkingTimePerFrame = 1000 / FRAMES_PER_SECOND; //this is optional
long lastStartTime = System.currentTimeMillis();
while(true)
{
lastStartTime = System.currentTimeMillis();
Tick();
long processingTimeForCurrentFrame = System.currentTimeMillis() - lastStartTime;
if(processingTimeForCurrentFrame < maxWorkingTimePerFrame)
{
try
{
Thread.sleep(maxWorkingTimePerFrame - processingTimeForCurrentFrame);
}
catch(Exception e)
{
System.err.println("TSEngine :: run :: " + e);
}
}
}
so how do i call :
public void paint( Graphics g ) {
}
in my Tick method?