Hi, everyone.
I have made a little script in which two characters are fighting each other.
I've used an array to be able to play more random weapon sounds.
The problem is that when I press space, after two or three times, I get this error and I don't have any clue what's going on.
I'll put the relevant parts of the code below
I define this array globally
sound[] laser(3);
And next, somewhere in a function I have this
for(int s=0; s<laser.length(); s++)
{
laser[s].load("Sounds/Laser Gun"+s+".ogg");
}
And then, I have a while with an if, where happens the following:
if space is pressed:
the enemy health decreases
then we have the laser_sound function
then is the enemy_attack function, and after that everything repeats until one of the two characters win the game.
Bellow you have the laser_gun function
void laser_sound()
{
int r=random(0, laser.length());
laser[r].play();
}
so, what do you think the problem might be for getting this error?