Skip to content

Show Title Screen #1

@CodeRhymesLife

Description

@CodeRhymesLife

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.

image

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 line

For 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:

  1. Below // Show Title Screen below this line create a new instance of TitleScreen and store it in a variable called screen. Your code for this step should look something like this:
    Screen screen = new TitleScreen();
  2. Now that you have an instance of TitleScreen stored in the variable screen, show it by calling screen.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:

image

Congratulations, you just fixed your first bug 🎉 🎈 😃!

After you have fixed this bug:

  1. Commit and push your changes to GitHub
  2. For groups, have each group member sync, run and test the latest code to make sure everything is working properly.
  3. Move on to Add Title Screen Controls #2!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions