Collision detection and scoring
Unlike in the Timber!!! game when we simply checked whether a branch in the lowest position was on the same side as the player's character, in this game, we will need to mathematically check for the intersection of the ball with the bat or the ball with any of the four sides of the screen.
Let's look at some hypothetical code that would achieve this so that we understand what we are doing. Then, we will turn to SFML to solve the problem for us.
The code for testing the intersection of two rectangles would look something like this. Don't use the following code. It is for demonstration purposes only:
if(objectA.getPosition().right > objectB.getPosition().left && objectA.getPosition().left < objectB.getPosition().right ) { // objectA is intersecting objectB on x axis // But they could be at different heights...