Getting Jerkyness with TimeDelta

Started by
13 comments, last by Neen10do 21 years, 1 month ago
quote:Original post by RhoneRanger
It is a modifier, just like your /8

0.02f just says it is a floating point number.

I am assuming that TimeDelta is a float.

multiplying by a modifier is much faster than dividing by one, so it will eliminate your jerkiness.


um...he said TimeDelta wasn't a float, and two: dividing by a float isn't much of a difference...sure, if you loop a million times a second it is, but at 30fps or so...nah...sorry...

(Neen - that dosn't mean you shouldn't still multiply rather than divide! (and again, /8 = *0.125 (or *0.125f)) )



quote:Original post by RhoneRanger
One more thing, you know that time elapsed should be calculated similar to this
float CurrentTime;
float LastTime;
float ElapsedTime;
LastTime=TimeGetTime();


begin loop
CurrentTime=timeGetTime();
TimeElapsed=CurrentTime-LastTime;
LastTime=CurrentTime;

do all your game stuff

end loop



He allready has a TimeDelta...he dosn't need to be told how to get one again (TimeElapsed = TimeDelta) (I hope, anyways...) (oh yeah, change the decleration from float ElapsedTime to TimeElapsed...it helps when the names are exactly the same).

[edited by - MaulingMonkey on March 3, 2003 9:37:41 PM]
Advertisement
I hope he meant like 8 miliseconds, but whatever!

still should multiply by a modifier than divide!
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno
well the TimeDelta/8 was because TimeDelta was making it too fast.

this basically did nothing if my timedelta was 8 (which it normally was). this eliminated the purpose.

so what i did then was create the speeds at decimals... then multipled by just TimeDelta.

this worked, but was a little weird, as well.

i used timeDelta * .02f (and returned the velocities back to whole numbers) and it was a lil slow, so i did 1.0f, not knowing what the hell i was doing, and it seemed to work ok--- that is, on my computer. my friend who usually tests my game on her machine just converted to win98 (i know i know) and is getting directx errors. so i cant tell if this time independent movement has made a difference.

would it?

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!
----------------------i code therefore i am.Aero DX - Coming to a bored Monitor near you!
quote:Original post by RhoneRanger
I hope he meant like 8 miliseconds, but whatever!

still should multiply by a modifier than divide!


Wouldn't be too teribly sure...I remember some great fun with a clock() function in time.h giving me hundredths of a second... which I had to multiply by 10 to prevent myself from getting horribly confused . And I still did agree that he should multiply ^_^.


quote:Original post by Neen10do
well the TimeDelta/8 was because TimeDelta was making it too fast.

this basically did nothing if my timedelta was 8 (which it normally was). this eliminated the purpose.

so what i did then was create the speeds at decimals... then multipled by just TimeDelta.

this worked, but was a little weird, as well.

i used timeDelta * .02f (and returned the velocities back to whole numbers) and it was a lil slow, so i did 1.0f, not knowing what the hell i was doing, and it seemed to work ok--- that is, on my computer. my friend who usually tests my game on her machine just converted to win98 (i know i know) and is getting directx errors. so i cant tell if this time independent movement has made a difference.

would it?

----------------------
i code therefore i am.

Aero DX - Coming to a bored Monitor near you!


Depends on how you got TimeDelta. If it's based on a function that returns things like milliseconds, hundredths of a second, or whatever, then yes it will make a difference.

If it's based on processor speed, well then it'll change for each computer (the speed), but it will definatly still keep the program running at a smooth pace on any computer (just faster/slower than you'd like ).

Gah...DX...*shudders* :-p


[edited by - MaulingMonkey on March 3, 2003 9:44:50 PM]
The only problem with what you just said (neen10d0) that if you multiply by 1.0f, you get the same result as if you did nothing!

any number * 1 = any number.

I personally use QueryPerformanceCounter for calculating TimeElapsed, but if you use timegettime, you should do your TimeDelta like I showed above, returning time in miliseconds.

*NOTE You shouldnt get directx errors by multiplying by a float???
TechleadEnilno, the Ultima 2 projectwww.dr-code.org/enilno

This topic is closed to new replies.

Advertisement