timebased TOKSIM_Advance

Blitz3D Forums/Blitz3D Userlibs/timebased TOKSIM_Advance

WildStorm(Posted 2005) [#1]
hi,
i've a problem with calling TOKSIM_Advance. I'd like to call the updatefunction timebased, but sth. like this:
repeat
fps = currentfps()
toksim_advance(1.5/fps,1)
until keydown(1)
does not work.
thx for your help

(and excuse my bad english ;)


Shifty Geezer(Posted 2005) [#2]
Just guessing, don't you need to float your fps?

fps#= float(currentfps())
toksim_advance(1.5/fps#,1)
until keydown(1)


Damien Sturdy(Posted 2005) [#3]
o.O youre the second person using this code ive seen this week. Is it a sample or something? That reminds me, i better tell the other guy....


WildStorm(Posted 2005) [#4]
no, it was my idea.
because in all tutorials you find:
const fps = 60

;...

toksim_advance(1.5/fps,1)

@Shifty Geezer
oh jea, i'll try this.

edit: no, this doesn't work.


WildStorm(Posted 2005) [#5]
ok, i found a solution. But it's not the nicest one.

toktimer%

;...

tok_tiks% = WaitTimer(toktimer%)
For I = 1 To tok_tiks%
TOKSIM_Advance(1.5/200,1)
Next


Is there maybe an other one?


Sweenie(Posted 2005) [#6]
I use const fps = 60 in many of my demos.
The fps constant is meant to be the number of physics updates per second.
You should use a fixed timestep for best results as a variable timestep can make even a RK4-integrator go bananas.

I recommend reading this timestep tutorial by Gaffer(Glenn Fiedler)
http://www.gaffer.org/articles/Timestep.html


WildStorm(Posted 2005) [#7]
oh, the master himself ;)
but the problem with constant fps is, that the game has not always 60fps, so the physics look sometimes very fast and sometimes like "bullettime"
but thx for the tutorial, i'll have a look at it :)


WildStorm(Posted 2005) [#8]
oh jea. works very fine (same speed with 60fps and 300 fps :)
thx very much!