How can I make random sound effects

BlitzMax Forums/BlitzMax Beginners Area/How can I make random sound effects

Emmett(Posted 2005) [#1]
I need a little help on this problem.

My first ever game is roughed in and works great. Now I'm adding a little polish to it.
The game now has a background song loop going for atmosphere and a clock ticking effect for the Bonus score count down.
I would like to add a few sound effects that play at random times and which sound plays is chosen at random.
I'm stumped for how to do this. Thanks


Yan(Posted 2005) [#2]
Something like:
Global AmbientSounds:TSound[10]
...
For a = 0 until TotalAmbientSounds
  AmbientSound[a] = Loadsound("snd\amb" + a + ".wav")
Next
...
if (Millisecs() - AmbientStartTime) > AmbientInterval
  playsound AmbientSound[rand(1, TotalAmbientSounds) - 1]
  AmbientInterval = rand(AmbientIntervalMin, AmbientIntervalMax)
  AmbientStartTime = Millisecs()
End if
...
Should do the trick.