-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Problem
Enemy ships are invisible! They move and shoot, but remain hidden like snipers 😱!
The reason they're invisible is because they are not drawn to the screen. After you fix this bug you will reveal their position and make the game a lot more fun.
Where Is The Problem?
File: src/entity/EnemyShipFormation.java
Function: draw()
Instructions
To fix this bug we need to draw each enemy ship. When you're done your game should look something like this:
To access and draw each ship we need to loop over the 2 dimensional array enemyShips 😱. Don't worry, you can do it, just follow the instructions below.
A two dimensional array is simply an array of arrays. Each ship is held in a row and each row is held in the variable enemyShips. We need to access each row in enemyShips, then each ship in the row. To access the first row, for example, we would write: enemyShips[0]. That would return the row of ships boxed in blue below.
To access the first ship in the first row we would write: enemyShips[0][0]. That would return the ship boxed in red below.
We could then draw that ship by passing it to the draw manager like this:
drawManager.drawEntity( enemyShips[0][0] );
Unfortunately, we don't know how many ships are in enemyShips because each level is different, so we need to use a for loop to access each row, then use another for loop to access each ship in that row. Once you have the ship call drawManager.drawEntity( <ship> );.
Your final code should look something like this:
for( ... ) {
for(...) {
drawManager.drawEntity( <ship> );
}
}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 Start Game With One Life #6 Change The Number Of Levels Played In Each Game #7 or Shoot Multiple Bullets From The Ship #8!



