We will now move on to create a new class by going through the following steps:
- Select the project in the solution explorer and then right-click and select Add | Class. In this class name, specify the name as Hero. You will see the .h and .cpp file sections automatically populated as Hero.h and Hero.cpp respectively. Click on Ok.
- In the Hero.h file, add the SFML graphics header and create the Hero class:
#include "SFML-2.5.0\include\SFML\Graphics.hpp" class Hero{ };
- In the Hero class, we will create the methods and variables that will be required by the class. We will also create some public properties that will be accessible outside the class, as follows:
public: Hero(); ~Hero(); void init(std::string textureName, sf::Vector2f position, float
mass); void update(float dt); void jump(float velocity); sf...