#pragma once #include #include #include #include #include #include #include #include "game_engine.hpp" #include 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; const sf::Color OUTLINE(50, 200, 25); constexpr int THICKNESS=10; const sf::Color FILL = sf::Color::Transparent; class SoundQuip { public: sf::Sound sound; sf::SoundBuffer buffer; bool initialized; SoundQuip() {}; void load(nlohmann::json &data, const char *file_key, bool loop=false); void play(); void stop(); }; class SFMLBackend { sf::ContextSettings settings; sf::RenderWindow window; sf::Clock clock; sf::Clock deltaClock; sf::Sprite face_sprite; sf::Texture face_texture; bool window_active_out = false; bool show_build_log = false; int hit_points = 50; sf::Font font; GameEngine &game; std::vector 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 &lines); sf::RectangleShape box(int x, int y, int width, int height, sf::Color fill=FILL, sf::Color outline=OUTLINE, int thickness=THICKNESS); void write_text(int x, int y, string content, float size_mult=1.0f); void Window_update(); };