samspade
Member
I'm trying to refine my delta time system. In side by side comparisons though I'm struggling to accomplish similarness. Maybe it is just what it is supposed to be but it seems a little strange. So all I have is two objects that do that fall to the bottom of the screen and bounce:
The delta time calculation is close. I'm printing out the value of _dt each step and it is always either 1 or averages to one within a frame or two. Probably wouldn't be noticeable if they weren't side by side, but side by side the non-dt version definitely starts faster and they become offsync.
If I just set vsp to a number and do y += vsp and compare that to y += vsp * _dt the results are the same.
I'm familiar with this: Delta time calculations. But The version listed there is significantly worse.
This is half experiment and half a project that uses a variety of dts simultaneously (e.g. can change game, enemies, player, particle system, etc. together or independently). So it isn't for frame rate issues it is for speed control.
Code:
//normal version
vsp += grav;
y += vsp;
if (y >= room_height) {
y = room_height;
vsp *= -0.9;
}
//delta time version
vsp += grav * _dt;
y += vsp * _dt;
if (y >= room_height) {
y = room_height;
vsp *= -0.9;
}
If I just set vsp to a number and do y += vsp and compare that to y += vsp * _dt the results are the same.
I'm familiar with this: Delta time calculations. But The version listed there is significantly worse.
This is half experiment and half a project that uses a variety of dts simultaneously (e.g. can change game, enemies, player, particle system, etc. together or independently). So it isn't for frame rate issues it is for speed control.