So after multiple unsuccessful attempts a debugging, I finally figured out that I'm too incompetent to figure this out on my own. Question one of two-- the scenario I'm working on utilizes a shotgun fire-and-reload sound effect. But the zeptosecond it stops playing, Greenfoot throws an out-of-bounds exception, exactly like this:
Exception in thread "Soundstream:file:/Z:/MyProject/sounds/mossberg.mp3" java.lang.ArrayIndexOutOfBoundsException: 580."
I've tried to fix this quite a few times, but to no avail. It just refuses to go away. How do I make it go away? Question two of two-- I've also had extreme difficulty getting opponents to spawn in this scenario. I have the code that I think is correct; I haven't used Greenfoot since August of 2015, so I'm not only incompetent, but I'm also out of practice. Here's the code I'm pseudocertain about:
What is it exactly that I'm doing wrong? And if I'm doing everything wrong, I wouldn't be surprised.
private int count = 0; //initialized in the Background class as opposed to the Background method, which is below
public Background() //This is the Background method that is added to the code by default
{
count++;
int position = (int)(Math.random()*3);
if(count % 10000 == 0)
{
if(position == 0)
this.addObject(new Grunt(), 125, 175);
else if(position == 1)
this.addObject(new Grunt(), 300, 175);
else
this.addObject(new Grunt(), 475, 175);
}
}

