I have been Stumped, I'm using the Eclipse IDE and am building a game using ATW and Swing. however, a random bug snuck its way into my script and I don't know how or why as this part of the code has not been touched in ages. Essentially I am using a switch statement to determine which images are to be loaded at what time to create a sort of intro sequence, Here is the script:
// condition that only runs once within the print function
if (gameState == "start")
{
//gameAudio.loopMusic(false);
//intro animation
switch(startCounter)
{
//3 and a half seconds of buffer split into 10 parts to allow for updating screen during startup of app
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
wait(350);
break;
case 10:
gameAudio.playMusic("src/res/audio/JackEditedIntro.wav");
gameAudio.setVolume(0.6);
wait(300);
samIcon = new ImageIcon("src/res/SamAssets/SamFullBody/SwingUpSam.png");
break;
case 11:
wait(40);
samIcon = new ImageIcon("src/res/SamAssets/SamFullBody/HighFiveSam.png");
samPow = new ImageIcon("src/res/SamAssets/SamFullBody/PowSam.png");
break;
case 12:
wait(100);
samIcon = new ImageIcon("src/res/SamAssets/SamFullBody/HighFiveSam.png");
samPow = new ImageIcon("");
break;
case 13:
wait(1200);
samIcon = new ImageIcon("src/res/SamAssets/SamFullBody/WaveSam.png");
break;
case 14:
wait(1200);
samIcon = new ImageIcon("src/res/SamAssets/SamFullBody/SwingUpSam.png");
break;
case 15:
wait(40);
samIcon = new ImageIcon("src/res/SamAssets/SamFullBody/IdleSam.png");
break;
case 16:
wait(500);
samIcon = new ImageIcon("");
break;
case 17:
wait(300);
gameAudio.playMusic("src/res/audio/BattleStart.wav");
wait(2000);
break;
default:
wait(5);
System.out.println("Default start up switch statement");
}
setBackground(Color.BLACK);
samIcon.paintIcon(this, g, 540, 20);
samPow.paintIcon(this, g, 720, 20);
//samIcon.ImageIcon();
if (startCounter < 17)
{
startCounter += 1;
}
else
{
//start the actual game
gameState = "menu";
//play the song
gameAudio.playMusic("src/res/audio/AllTheWay.wav");
gameAudio.setVolume(0.2);
gameAudio.loopMusic(true);
// default Sam
samIcon = new ImageIcon("src/res/SamAssets/IdleSam.png");
}
}
The Issue is that not all of my images are being loaded and some sound files are not playing (I quintuple checked the source files which, again, have not been touched for ages and should not be part of the problem). The script appears to be skipping case 11, case 13, case 15 and case 17 so my best guess would be that the script is skipping every second case condition (hard for me to verify if it is skipping in the earlier parts of the statement), but i haven't the faintest as to why. If anyone could shine some light on my issue I would greatly appreciate it.
PS: This is only my second huge coding project in my entire life and so I deeply apologize for the damningly terrifying coding style and hope you can forgive me, thank you.
Update: I added a System.out.println to every case incrementation and every number is appearing in the console despite the images and audio not being loaded in those same cases. Consider me 200% more confused, I desperately need help.