This commit is contained in:
Crizomb 2025-06-10 17:40:16 +02:00
commit f698a38c7e
585 changed files with 118338 additions and 0 deletions

View file

@ -0,0 +1,38 @@
#ifndef BOOK_GAME_HPP
#define BOOK_GAME_HPP
#include <SFML/Graphics.hpp>
class Game {
public:
Game();
Game(const Game &) = delete;
Game &operator=(const Game &) = delete;
void run();
private:
void processEvents();
void update(sf::Time elapsedTime);
void render();
void updateStatistics(sf::Time elapsedTime);
void handlePlayerInput(sf::Keyboard::Key key, bool isPressed);
static const float PlayerSpeed;
static const sf::Time TimePerFrame;
sf::RenderWindow mWindow{sf::VideoMode({640, 480}), "SFML Application"};
sf::Texture mTexture;
sf::CircleShape mTarget;
sf::Font mFont;
sf::Text mStatisticsText{mFont};
sf::Time mStatisticsUpdateTime;
std::size_t mStatisticsNumFrames{0};
bool mIsMovingUp{false};
bool mIsMovingDown{false};
bool mIsMovingRight{false};
bool mIsMovingLeft{false};
};
#endif // BOOK_GAME_HPP

View file

@ -0,0 +1,11 @@
#ifndef BOOK_STRINGHELPERS_HPP
#define BOOK_STRINGHELPERS_HPP
#include <sstream>
// Since std::to_string doesn't work on MinGW we have to implement
// our own to support all platforms.
template <typename T> std::string toString(const T &value);
#include "StringHelpers.inl"
#endif // BOOK_STRINGHELPERS_HPP

View file

@ -0,0 +1,6 @@
template <typename T> std::string toString(const T &value) {
std::stringstream stream;
stream << value;
return stream.str();
}