Blitz2D Newbies: Dealing with Multiple Music Channels
by Erebel55

This tutorial is for all you newbs to blitzcoder. We will be learning how to put music into are code and how to switch back and forth between channels.


The use of this technique would be like in my game the Enchanted Cities were i have a random number going on which would be change_variable in the source code above. Once this variable hits 1 it takes you into a battle screen were you fight a monster. Were the chaneled music fits into all this is that once the change_variable hits 1 the music changes and thats what I wanted in my game the music to change once you went into the battle screen. This is also useful for a space invader game were when the boss spawns you want the music too change to something more fast paced. Well those were just a few examples of when you would want to use this kind of thing. Now lets go over the code together.


This first bit of code just loads and gives the 2 music pieces pointers that I can call with.


This part of code just sets the variable for the random number and prepares sndwave for looping.


This section firstly starts playing sndWave. Next it prints playing sound for 2 seconds of the screen and waits 2 seconds while sndWave is playing. Next it prints changing channels and it stops chnWave + delays for 2 seconds.


This part of the code is like the when you have entered the battle arena and you want the music to change or you have started to fight a boss it changes the music and waits 20 seconds while its playing.


This is what happens when you do not enter the battle or you are not fighting a boss the music stays the same and it waits 5 seconds.


This last part of the code just stops the channel once everything is done. Ok that is all I have for you. This was my first tutorial so dont be to harsh on me. If you have any questions email me at redviper@email.com. Or my aim is Erebel7449 and my msn is redviper8@hotmail.com. I hope I helped some of you people who were having trouble dealing with music. Erebel55


For a printable copy of this article, please click HERE.


This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.