|
|
|
#pragma once
|
|
|
|
#include <SFML/System.hpp>
|
|
|
|
#include <SFML/Graphics/RenderWindow.hpp>
|
|
|
|
#include <SFML/Graphics/Sprite.hpp>
|
|
|
|
#include <SFML/Graphics/Font.hpp>
|
|
|
|
#include <SFML/Audio.hpp>
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include "game_engine.hpp"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
constexpr int FPS=30;
|
|
|
|
constexpr int X_DIM = 1920 / 2;
|
|
|
|
constexpr int Y_DIM = 1080 / 2;
|
|
|
|
constexpr int TEXT_SIZE = 48;
|
|
|
|
constexpr int Y_LINES = 23;
|
|
|
|
constexpr int X_ROWS = 48;
|
|
|
|
|
|
|
|
class SoundQuip {
|
|
|
|
public:
|
|
|
|
sf::Sound sound;
|
|
|
|
sf::SoundBuffer buffer;
|
|
|
|
bool initialized;
|
|
|
|
|
|
|
|
SoundQuip() {};
|
|
|
|
|
|
|
|
void load(nlohmann::json &data, const char *in_file);
|
|
|
|
void play();
|
|
|
|
void stop();
|
|
|
|
};
|
|
|
|
|
|
|
|
class SFMLBackend {
|
|
|
|
sf::ContextSettings settings;
|
|
|
|
sf::RenderWindow window;
|
|
|
|
sf::Clock clock;
|
|
|
|
sf::Clock deltaClock;
|
|
|
|
sf::Sprite background;
|
|
|
|
sf::Texture texture;
|
|
|
|
bool window_active_out = false;
|
|
|
|
bool show_build_log = false;
|
|
|
|
int hit_points = 50;
|
|
|
|
sf::Font font;
|
|
|
|
GameEngine &game;
|
|
|
|
std::vector<string> log;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SFMLBackend(GameEngine &g);
|
|
|
|
|
|
|
|
// prevent copy
|
|
|
|
SFMLBackend(SFMLBackend &g) = delete;
|
|
|
|
|
|
|
|
void startup();
|
|
|
|
|
|
|
|
bool is_open();
|
|
|
|
void shutdown();
|
|
|
|
|
|
|
|
void handle_events();
|
|
|
|
void update_entities();
|
|
|
|
void update_log(std::vector<string> &lines);
|
|
|
|
|
|
|
|
void write_text(int x, int y, string content);
|
|
|
|
|
|
|
|
void ImGui_setup();
|
|
|
|
void ImGui_update();
|
|
|
|
void Window_update();
|
|
|
|
};
|