[SDL] Delta time?
Justin Coleman
jmcoleman at gmail.com
Fri Oct 12 17:40:16 PDT 2007
Quick and dirty way might be to determine how many frames your
timestep is equivalent to, and use that as the % slowdown.
On 10/12/07, L-28C <kixdemp at gmail.com> wrote:
> Yep, I can't seem to figure out a way to "tweak" the slowdown... :/
>
> Justin Coleman wrote:
> > Multiply your framerate (60/sec?) by each of those numbers to get the
> > total change per second, then multiply the per-second value by however
> > much (fractional seconds) time between frames. The 1% deceleration may
> > need to be tweaked, since it's dependent on the current speed and not
> > a fixed value.
> >
> > On 10/12/07, L-28C <kixdemp at gmail.com> wrote:
> >> Hello people of SDL!
> >>
> >> I've been capping the framerate in my games the last few times, but I
> >> want to give delta time a try... Here's the code I have modified to work
> >> with DT:
> >>
> >> -----------------------
> >> oldTime = SDL_GetTicks();
> >>
> >> while (1)
> >> {
> >> newTime = SDL_GetTicks();
> >> delta = newTime - oldTime;
> >>
> >> /* Update control status */
> >> handleControls(controls);
> >>
> >> /* TODO: Pause, not exit */
> >> if (controls[K_PAUSE]) exit(0);
> >>
> >> /* Process game logic */
> >> doLogic(delta);
> >>
> >> /* Render our scene */
> >> renderBackground();
> >> render(0);
> >>
> >> /* So we don't use 100% CPU */
> >> SDL_Delay(1);
> >>
> >> oldTime = newTime;
> >> }
> >> -----------------------
> >>
> >> In doLogic(), what I had done while capping FPS was add 0.05f to the
> >> ball's speed (acceleration) and multiply by 0.99f (deceleration).
> >>
> >> But how would I modify those values to work with my delta?
> >>
> >> Thanks!
> >>
> >> _______________________________________________
> >> SDL mailing list
> >> SDL at lists.libsdl.org
> >> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
> >>
>
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>
More information about the SDL
mailing list