SFML Template to start with your game
If you have setup SFML with the tutorial that I wrote, the example is easy but is not very useful if you want to create more complex games. In this post, I going to show you how I create a simple Game class to have more control about the game loop, the user input and the frame rate. First, you need to create a Game.h and Game.cpp files. In your Game.h write this code #ifndef GAME_H #define GAME_H #include <SFML/Graphics.hpp> class Game { public: Game(); void Run(); private: void processEvents(); void update(sf::Time deltaTime); void render(); void handlePlayerInput(sf::Keyboard::Key key, bool isPressed); sf::RenderWindow mWindow; …