Computer Science Canada

playing gun shot sounds repeately

Author:  omni [ Sun May 02, 2004 6:15 pm ]
Post subject:  playing gun shot sounds repeately

Gun shot sounds are driving me crazy.
ex:
process gunshot
Music.PlayFile("gunshot.wav")
end gunshot
loop
if userpressedshoot then
fork gunshot
end if
end loop

The problem with this is that every time the user shoots, the gunshot.wav is repeately starting over and over and can never finish playing. Any ideas how to play gun shot noises like Counter-Strike does?

Author:  GreenTiger [ Sun May 02, 2004 7:18 pm ]
Post subject: 

You've got to have a delay of some kind or another. One that stop the user from firing too quickly. If you want them to be able to fire at a certain speed, then start from there and set that delay, then modify your sound to fit.
If you want the sound to fit the game, time the length of the sound with an editor of some kind and set the delay to be that long.

Author:  Mazer [ Mon May 03, 2004 4:43 am ]
Post subject: 

A delay might help but it won't completely solve the problem. As stated many times before, turing can only play one sound of each type (ie, one wav, one mp3, one [whatever that other thing is]). So, if you're shooting, every time it gets to the line "Music.PlayFile("gunshot.wav")" turing stops whatever wav file may already be playing and starts to play the file you just told it to.

Author:  omni [ Mon May 03, 2004 2:30 pm ]
Post subject: 

so theres NO good solution to this problem?
GRR...

Author:  GreenTiger [ Mon May 03, 2004 8:57 pm ]
Post subject: 

Yeah, you CANNOT have two gunshots at the same time. You CAN settle for having a long enough delay to make sure the gunshot sounds CAN'T sound over each other.

And that IS a good solution.

Basically change your sound file to fit a certain delay or change your delay to fit a certain length.

So kinda like what I said the first time around.

However, there will be NO way for enemies to also have their guns fire...

Author:  gamer [ Tue May 04, 2004 12:57 pm ]
Post subject: 

that sucks then......but im sure theres a better way

Author:  Paul [ Tue May 04, 2004 1:47 pm ]
Post subject: 

Maybe shorten the sound and make sure you don't have a bunch of inputs stacked up in the buffer. (does mouse work that way?)

Author:  white_dragon [ Tue May 04, 2004 2:07 pm ]
Post subject: 

just use a music program to merge da two gun shots goin of at da same time. it should work. or like paul said, make the sound shorter....


: