Blitz+ Timing issues

BlitzPlus Forums/BlitzPlus Programming/Blitz+ Timing issues

Eikon(Posted 2003) [#1]
Ive been using CreateTimer(60) before repeat/forever and rendering everything during my Timer Tick $4001 event. I discovered I have problems with the MilliSecs() values I get while in this event. For instance saying X = MilliSecs() at some point in the tick event and then saying If MilliSec() >= X + 10000, it will fire without any wait at all. Im also starting to notice things getting jerky and unsmooth. Is delta time a good thing to implement in b+ with event driven input? Is there another good 2D timing method I can use with an otherwise event driven setup?


Eikon(Posted 2003) [#2]
Let me try to phrase this better...

This doesnt work:
GameTime = CreateTimer(60)
AnotherTimer = MilliSecs()
Repeat
Select WaitEvent(1)
     Case $4001
          If MilliSecs() >= AnotherTimer + 1000 then X = X
End Select
Forever


I want to handle timing of character animation and such in my main game loop (tick event) so how can I get the above to fire?


skidracer(Posted 2003) [#3]
See here for why not to use Millisecs() in that way

http://www.blitzbasic.com/bbs/posts.php?topic=16680

So in theory MilliSecs()-AnotherTime>1000 might fix your problem.

In your situation a timeout variable that you initialize with 60 and decrement every event (trigger secondary event when it hits zero) would be best I think.

btw, you do know x and X are the same variable in blitz


Michael Reitzenstein(Posted 2003) [#4]
That would only buy you another second though? I would base your timing on timer ticks because there is a function that will return ticks since creation.


Eikon(Posted 2003) [#5]
Yes skid, it was just an example. Also I would reset my Timer to MilliSecs() of course. I tried the one liner and it worked the first time but never again. Ill read the thread but Ill end up using variable counters I think.

Thanks for your help.