Hi Rorkien thanks you!
you helped me to undestand some points
I'm working with fixed framerate, and the gameloop is implemented with the target to converge the number of UPS to a costant number each second, and this number is the TARGET_FRAME_SECOND that i use to calculate the duration time of the period
1
| long period = (1000/TARGET_FRAME_SECOND) |
and to mantain costant this number of UPS i'm also ready to skip same frames.
you really shouldn't care about delta
yes you are right, i shouldn't care the delta if the period is defined (this is the response to my question)
So, i guess the point of that frameskipping is to update the game based on a standard update period, or your period variable
this is also true and to ensure this, finally the last game update has sense
if the normal cicle is execute in less the period time sleep appear, instead if the execution time take more
i save the overtime related to cicle update,render and paint and save in the
excess variable
becouse the period can be execute with more that that a period time
1 2 3 4 5 6 7 8 9 10 11 12
| if (sleepTime > 0) { ... ... }else { [b] excess[/b] -= sleepTime; overSleepTime = 0L;
if (++noDelays >= NO_DELAYS_PER_YIELD) { Thread.yield(); noDelays = 0; } } |
and when the excess is more that a period time i can run all the update to reach the target of number of UPS for second if i'm in delay
1 2 3 4 5 6 7
| int skips = 0; while((excess > period) && (skips < MAX_FRAME_SKIPS)) { excess -= period; game.updateGame(); skips++; } |
so the period is the time to pass to the update