My applet creates a new sound every time an impact occurs, which is very frequently.

How come, when the sounds become too numerous, the game ceases to run smoothly?

Here is the code that gets called many, many times:

class soundThread extends Thread
{
    String sound;
    soundThread(String i_sound)
    {
        sound = i_sound;
    }
    public void run()
    {
        try{
            URL path = new URL(getClass().getProtectionDomain().getCodeSource().getLocation(), sound+".wav");
            AudioClip clip = Applet.newAudioClip(path);
                //checkpoint A
            clip.play();
                //checkpoint B
        }catch(Exception e){System.err.println("err= soundThread_error");e.printStackTrace();}
    }
}

The longest pause occurs at clip.play();. Any clue why it would take so long to play the clip? And how can I fix it?

Did you read the API doc for the AudioClip class?

No, sorry. But upon searching for it I did not find anything helpful :/

It explains what the code does. It doesn't say how to change what it does.
If you want the sounds to play sequentially, you'll have to write code to call play() after the last clip has finished.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.