I’m posting this here because it’s stupid and I should know better considering this is what I was doing back in my 10th grade, hence I need to be shot for stupidity.
Does this code do 30 ticks per second?
int ticks = 30;
long start = System.nanoTime();
//do logic
if(end >= (1e-9/60) && ticksDone <= ticks){
logicLoop(clickLoc, mouseLoc, playerCamera);
ticksDone++;
}
if(ticksDone == 30)
ticksDone = 0;
end = System.nanoTime() - start;
I’ve corrected it to this:
int ticks = 60;
long start = System.nanoTime();
double time = 30 / Math.pow((1e-9/1)*10, 9);
if(end <= time && ticksDone <= ticks){
logicLoop(clickLoc, mouseLoc, playerCamera);
ticksDone++;
}
if(ticksDone == 30)
ticksDone = 0;
end = System.nanoTime() - start;
