Using the Bat class and coding the main function
Switch to the main.cpp
file that was automatically generated when we created the project. Delete all its auto-generated code and add the code that follows.
Code the Pong.cpp
file as follows:
#include "Bat.h" #include <sstream> #include <cstdlib> #include <SFML/Graphics.hpp> int main() { // Create a video mode object VideoMode vm(1920, 1080); // Create and open a window for the game RenderWindow window(vm, "Pong", Style::Fullscreen); int score = 0; int lives = 3; // Create a bat at the bottom center of the screen Bat bat(1920 / 2, 1080 - 20); // We will add a ball in the next chapter // Create a Text object called HUD ...