You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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> );.
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 inenemyShips, 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
enemyShipsbecause 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 calldrawManager.drawEntity( <ship> );.Your final code should look something like this:
After you have fixed this bug: