|
|
|
|
 |
| Learn about vectors as you create an array of cannonballs that can be launched by the player's cannon and fly across the game screen. |
|
 |
Step 1 |
|
|
|
| Add new variables to your GameObject class to allow for objects that have velocity and that can toggle between alive and dead modes. |
|
|
|
|
|
Step 2 |
|
|
|
| Create and initialize an array of new cannonball GameObjects that can be fired by the player. |
|
|
|
|
|
Step 3 |
|
|
|
| Draft a new UpdateCannonBalls method that will move the cannonballs across the screen when fired. |
|
|
|
|
|
Step 4 |
|
|
|
Create a FireCannonBall method that will use the rotation of the cannon to fire a cannonball at the proper position and velocity.
Note: See the update for this step to fix a known problem. |
|
|
|
|
|
Step 5 |
|
|
|
| Modify the UpdateCannonBalls method to "kill" cannonballs that go outside of the screen bounds, to allow the player to fire more. |
|
|
|
|
|
Step 6 |
|
|
|
| Draw the cannonballs on screen inside the Draw call, so the player can see them when they are fired. |
|
|
|
|
|
|
|