The goal for the test is to write a “Pong”-like game.
(1 pt) Create separate header and source ﬁle for every class that you create.
1. (1 pt) Create a Player class that will be a rectangular table tennis racket of a
player. This class should derive from appropriate SFML class and, when the object
is created, it should set appropriate size and starting position (right window
border). Display the Player object on the screen.
2. (1 pt) Create a Ball class that will be a circular ball. This class should derive from
appropriate SFML class and, when the object is created, it should set appropriate
size and starting position (center of the window). Display the Ball object on the
3. (2 pts) Add a step method to the Player class. It should move the racket with
some constant speed (in pixels per second) depending on the user input (pressing
arrow up or arrow down). Start using the step method in the main loop of your
4. (3 pts) Add a step method to the Ball class. It should move the ball with some
constant speed (in pixels per second) so that it bounces off the window borders
that are different than the border at which player racket is located (right border).
Start using the step method in the main loop of your program.
5. (4 pts) Add bouncing off the racket and closing the game when the ball touches
the window border at which the player’s racket is located.
6. (2 pts) Add some ﬂag to the Player class that allows to create the racket for the
second player. The racket should be located at the window border opposite to the
ﬁrst player’s racket (it will be the left window border). Position of the racket should
be controlled withWand S keys.
7. (3 pts) MAKE A COPY OF YOUR CODE BEFORE APPROACHING THIS TASK!
Add additional base class called AnimatedObject the will require classes that
derive from it to implement the step method. Modify your code so that Player and
Ball classes both derive from AnimatedObject. Using appropriate type casts and
std::unique_ptr to create a polymorphic container that stores all scene objects and
start updating the scene view by looping over that container.
8. (5 pts) Add the Obstacle class that will be a rectangle appearing every some
number of seconds at random positions on the scene (but close to the middle of
the window). The ball should bounce back when it hits the obstacle. When there is
a collision the obstacle should disappear and reappear after some time at different
Hint: the obstacle object does not need to be deleted – it can be hidden by
decreasing its size to 0px or changing the color and switching the collision off.