Graphics In Time With Music ?
BlitzMax Forums/BlitzMax Beginners Area/Graphics In Time With Music ?| 
 | ||
| I was just wondering if somebody here could give me some basic tips on how to do this ? At the moment,depending on what resolution I am running in,the graphics either finish before or after the music has finished. Just would like to some basics of how to achieve this,thanks :) | 
| 
 | ||
| Only you can answer this as only you know how long the music is you are wanting to use. | 
| 
 | ||
| Sounds bit like you would need delta timing. If so, there are tutorials in this forum. -Henri | 
| 
 | ||
| perhaps a simple "WaitTimer() would be already sufficient.... Grahpics ...
Global FPS:TTimer=CreateTimer(60)
....
Repeat
    Cls
    Draw....
    ....
    Flip 0
    WaitTimer FPS
Until KeyHit(Key_Escape) | 
| 
 | ||
| What Timers are used for in general? | 
| 
 | ||
| Some example source code / more explanation would help a lot. | 
| 
 | ||
| Ok,what I am trying to do is,to draw a picture, X amount of pixels at a time until the picture is finished. As soon as the above process begins,I have a sound sample being played aw well. And I would like the graphics rendering to finish at the same time that the sound sample does. In my case the sound sample lasts for about 20 seconds. | 
| 
 | ||
| @Hard: They are used to make sure that your code / events run at a certain speed on every system (low or high end machine). @Drex: This might be enough... SuperStrict Global Counter:Int ' Load sound sample Global Timer:TTimer=CreateTimer( 1 ) ' Create a Timer that ticks once per second ' Start to play sound Print "Entering Main loop..." Repeat Counter=TimerTicks( Timer ) Print "Timer Ticks = "+Counter Print "Draw "+Counter*5+"% of the image..." Print "-----" WaitTimer( timer ) 'wait for the next tick Until TimerTicks( timer ) = 21 ' 20 seconds are over End | 
| 
 | ||
| With what Grisu indicated above, the draw command would work like this inside that loop:[bbcode] 'On the declaration block of your program... Local logo:TImage = LoadImage(...) Local x:Float = ... Local y:Float = ... Local iWidth:Int = ImageWidth(logo) Local iHeight:Int = ImageHeight(logo) 'Inside the loop... DrawImageRect(logo, x, y, iWidth * (Counter*5.0/100.0), iHeight) 'Image should progressively fill the screen horizontally from left to right. [/bbcode]PS: I think the loop should end at tick '20' though, not '21'. PPS: If you need smoother control (i.e. not quantized to seconds, but down to milliseconds if your sound lasts a fractional time, say, 19.853), you can use a Millisecs() counter. Search the forums for example usage. | 
| 
 | ||
| Thanks guys for your examples. I at least now,know where to start. I just needed pointing in the right direction :) | 
| 
 | ||
| you can also use the following: Delay(time) where time is a delay in milliseconds (1000 per second) |