51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
//
|
|
// Created by m on 12/3/21.
|
|
//
|
|
|
|
#ifndef RLA_IIPP_ENGINE_HPP
|
|
#define RLA_IIPP_ENGINE_HPP
|
|
#define FMT_HEADER_ONLY
|
|
#include <memory>
|
|
#include <chrono>
|
|
#include "game/game.hpp"
|
|
#include <fmt/format.h>
|
|
#include "rendering/renderer.hpp"
|
|
#include "input/inputprocessor.hpp"
|
|
static const std::string MISSING_GAME = "Game pointer is null";
|
|
static const std::string MISSING_RENDERER = "Renderer pointer is null";
|
|
static const bool SHOW_FPS = true;
|
|
static const std::string RESOURCE_DIR = "assets";
|
|
static const TextRenderDetails DEFAULT_FONT = TextRenderDetails(
|
|
"fonts/Consolas-Regular.ttf",
|
|
12,
|
|
COLOR_WHITE
|
|
);
|
|
class Engine {
|
|
public:
|
|
Engine(std::unique_ptr<Game> game, std::unique_ptr<Renderer> renderer,
|
|
std::unique_ptr<InputProcessor> input_processor);
|
|
void start_loop();
|
|
|
|
|
|
virtual ~Engine();
|
|
|
|
private:
|
|
std::unique_ptr<Game> game = nullptr;
|
|
std::unique_ptr<Renderer> renderer = nullptr;
|
|
std::unique_ptr<InputProcessor> input_processor = nullptr;
|
|
std::chrono::time_point<std::chrono::system_clock> render_fps(std::chrono::time_point<std::chrono::system_clock> end, std::chrono::time_point<std::chrono::system_clock> lastframe);
|
|
};
|
|
|
|
class MissingGameException : public std::exception {
|
|
public:
|
|
const char *what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW override;
|
|
};
|
|
|
|
class MissingRendererException : public std::exception {
|
|
public:
|
|
const char *what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW override;
|
|
};
|
|
|
|
|
|
#endif //RLA_IIPP_ENGINE_HPP
|