Summary
In this chapter, we discovered the basics of OOP, such as how to code and use a class, including making use of encapsulation to control how code outside of our classes can access the member variables but only to the extent and in the manner that we want it to. This is just like SFML classes, which allow us to create and use Sprite
and Text
instances, but only in the way they were designed to be used.
Don’t concern yourself too much if some of the details around OOP and classes are not entirely clear. The reason I say this is because we will spend the rest of this book coding classes, and the more we use them, the clearer they will become.
Furthermore, we have a working bat and a HUD for our Pong game.
In the next chapter, we will code the Ball
class and get it bouncing around the screen. We will then be able to add collision detection and finish the game.