-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Your first bug! What an exciting moment 😃!!! I'm so proud I might 😭.
This bug is pretty easy. It's meant to get you familiar with GitHub and the Invaders code, and get you off to a running start. Let's get started!
Compile and run your program.
Problem
Nothing shows when we start the program 😱! Don't worry, we'll get things working.
Nothing is showing because I removed the code that shows the first screen. You need to add it back to fix this bug. When this bug is fixed, running your code should show the TitleScreen.
Where Is The Problem?
File: src/engine/Invaders.java
Function: run()
Instructions
Open Invaders.java then find the run() function. You should see something like this:
// Get a list of levels to play
List<GameSettings> levelSettings = Levels.getLevels();
// Hold on to all of the game's information
GameState gameState = new GameState(1, 0, Constants.MAX_LIVES, 0, 0);
// Show Title Screen below this lineFor now, ignore everything above // Show Title Screen below this line. We won't use the code above that line until bug #3. In this bug we want to create and show a new TitleScreen. To do that, follow these 2 instructions:
- Below
// Show Title Screen below this linecreate a new instance ofTitleScreenand store it in a variable calledscreen. Your code for this step should look something like this:
Screen screen = new TitleScreen(); - Now that you have an instance of
TitleScreenstored in the variablescreen, show it by callingscreen.show();. Your code for this step should look something like this:screen.show();
After completing the above 2 steps run() should look something like this:
// Get a list of levels to play
List<GameSettings> levelSettings = Levels.getLevels();
// Hold on to all of the game's information
GameState gameState = new GameState(1, 0, Constants.MAX_LIVES, 0, 0);
// Show Title Screen below this line
Screen screen = new TitleScreen();
screen.show();Compile and run the updated code. You should now see the title screen when the program starts:
Congratulations, you just fixed your first bug 🎉 🎈 😃!
After you have fixed this bug:
- Commit and push your changes to GitHub
- For groups, have each group member sync, run and test the latest code to make sure everything is working properly.
- Move on to Add Title Screen Controls #2!
