In this chapter, we will make our project more flexible by adding game objects as classes instead of adding them to the source.cpp file. In this case, we will use classes to make the main character and the enemy. We will create a new rocket class that the player will be able to shoot at the enemy. We will then spawn enemies at regular intervals along with new rockets when we press a button. We will finally check for a collision between the rocket and the enemy and, accordingly, remove the enemy from the scene.
This chapter will cover the following topics:
- Starting afresh
- Creating the Hero class
- Creating the Enemy class
- Adding enemies
- Creating the Rocket class
- Adding rockets
- Collision detection