Creating Realtime delays ...

BlitzPlus Forums/BlitzPlus Programming/Creating Realtime delays ...

DNielsen(Posted 2004) [#1]
@all
Now, I finally figured out how to use loadanimimage() and displayimage(), but what is the best method to "delay" an animation sequence? blitz is so fast my animation is FAST ... too fast! need to slow it down by some kind of counter!


Bremer(Posted 2004) [#2]
Use Millisecs() and a counter variable perhaps.


WolRon(Posted 2004) [#3]
There is also WaitTimer(), but MilliSecs() is probably the command you are looking for.


Eikon(Posted 2004) [#4]
Example:
MyImg = LoadAnimImage("pic.png", 16, 16, 0, 5)

Local imgF% = 0, Time% = MilliSecs()

Repeat

DrawImage MyImg, 0, 0, imgF
If MilliSecs() >= Time + 100 then 
     If imgF < 4 then imgF = imgF + 1 else imgF = 0
     Time# = MilliSecs()
endif

Until KeyDown(1)
*edit*

@Wolron: Oops, all better.


WolRon(Posted 2004) [#5]
Time# = MilliSecs()

Pointless to assign MilliSecs() to a float since it returns an integer.


DNielsen(Posted 2004) [#6]
so everyone uses Milisecs() ?? no-one uses any kind of VBLANK ??


VIP3R(Posted 2004) [#7]
VBlank... that was on the Amiga wasn't it?

No, VBlank would be the same as VWait in Blitz (i.e. wait for next vertical blank event on the monitor) but because monitors have various refresh rates 60Hz,85Hz etc you won't have precise control of timing on machines that have different refresh rates.

The Amiga wasn't affected in this way as its refresh rates were all the same.

MilliSecs() would be your best bet as suggested above.


Bremer(Posted 2004) [#8]
You cannot change the background color of each line on a PC like you could on an Amiga. With a PC you have to draw everything. There isn't any raster/copper list to do this for you.