Background: I have some experience in programming, but it's not a lot and not very good. I'm taking my first Java class this year, but because the pace is so slow I decided to just learn with the aid of the internet. This is how I have learned most of what I know so far. The most recent thing I've learned are Sockets, if that gives you an idea of what level I'm at.
Context: I am creating a small multiplayer game played through a standalone applet: a 2D shooter where the player(s) have to defeat a barrage of NPC bots using guns and explosives as they progress further into enemy territory. The guns' stats differ throughout the game depending on other variables
Problem: Now that I have made a solid foundation (though still buggy), I want to add audio/sound effects. I don't know how to do this, let alone how to do it efficiently
What is the optimal way to add sound effects if they play repeatedly (e.g. firing a gun), often before the previous iteration has stopped?
I want to have a single sound for all the different guns (maybe a few sounds that alternate). The rate of fire is not constant. Will I have to call a method for every bullet? Do I have to make a new thread each time I play it? I've searched Google and found some ways to add sound/music, but I'm still not too sure if that's how I should approach this.
If it's too complicated I won't even bother. Thanks in advance.
edit: the guns' firing sounds are not the only sounds. There are various other sfx such as helicopter sounds, rockets launching, rockets travelling, bullets whizzing if they come close to you, explosion, tank noises, parachute sounds, dying sounds, etc. Is this too much? Does having lots of sound impact the game's performance?
irrelevant: why am I not allowed to create new tag(s): sfx, repeating, often?
Edited 4 Years Ago by kedxu