I couldn't really find a way to describe this in the the title so here goes.
I've been working on my little game this morning, added a nice zoom effect, a crouch feature and am now trying to add walking sounds. It doesn't work very well.
The problem is that the sound isn't stopped from playing more than one at a time resulting in a horrible screeching of hundreds of sound copies at a time.
Code:
sound run_wav = <run.wav>;
sound startrun_wav = <suddenwalk.wav>;
function run()
{
var startedrunning;
var running;
if (snd_playing(startedrunning) == 0)
{
startedrunning = ent_playsound (player, startrun_wav, 50); // play the bullet sound at a volume of 100
}
while (key_w > 0)
{
if (snd_playing(running) == 0)
{
running = ent_playsound (player, run_wav, 100);
}
sleep(0.01);
wait (1);
}
snd_stop (running);
snd_stop (startedrunning);
}
The first sound
startedrunning is the sound of the player's equipment rattling. The second one,
running, is the running loop. I was originally playing with loops but due to the sound bug I decided to make it a sound for now.
It might just be me not being awake yet, but I can't seem to solve it, even when using variables such as:
Code:
var soundisplaying;
if (soundisplaying == 0)
{
---play the sound---
soundisplaying = 1;
}
Bah.