League Invaders Pt. 9
ObjectManager
1. Go to your GameObject class. Create a boolean member variable called isAlive. This will let us know when a particular game object no longer needs to be saved in memory. Initialize it to true since all our game objects will start out alive.
2. Create a new class called ObjectManager
3. In the member variables, create a Rocketship object but DO NOT INITIALIZE IT.
4. Change the ObjectManager constructor so that it takes in a Rocketship object and use that to initialize the Rocketship member object.
5. Create a method called update that calls the update method from the Rocketship object.
6. Create a method called draw that takes in a Graphics object. This method then calls the draw method from the Rocketship object, passing in the graphics object.
7. Inside the GamePanel class, create and initialize an object of the ObjectManager class. Don't forget to pass in the GamePanel's Rocketship object.
8. In the updateGameState method, delete the call to the update method of the Rocketship class.
9. In the updateGameState method, use your ObjectManager object to call its update method.
10. In the drawGameState method, replace the call to the Rocketship draw method to a call to the draw method of the ObjectManager. Don't forget to pass in the Graphics object.
11. Run your game. You should see no change from Pt. 8.