diff --git a/assets/build_success.png b/assets/build_success.png new file mode 100644 index 0000000..c7985ed Binary files /dev/null and b/assets/build_success.png differ diff --git a/gui.cpp b/gui.cpp index d5c8d54..06346ec 100644 --- a/gui.cpp +++ b/gui.cpp @@ -7,8 +7,8 @@ #include #include #include -#include #include "builder.hpp" +#include #include using std::string, std::vector; diff --git a/sfmlbackend.cpp b/sfmlbackend.cpp index d02015a..1e7ce11 100644 --- a/sfmlbackend.cpp +++ b/sfmlbackend.cpp @@ -10,6 +10,8 @@ #include #include #include "sfmlbackend.hpp" +#include +#include using namespace fmt; using namespace nlohmann; @@ -109,8 +111,9 @@ sf::RectangleShape SFMLBackend::box(int x, int y, int width, int height, void SFMLBackend::update_entities() { window.clear(); - sf::RectangleShape face_box = box(2, 2, - X_ROWS/4, Y_LINES/2, sf::Color(100, 250, 200)); + sf::RectangleShape face_box = box(2, 2, X_ROWS/4, Y_LINES/2); + face_sprite.setPosition(translate(2,2)); + window.draw(face_sprite); sf::RectangleShape stats_box = box(X_ROWS/4 + 4, 2, X_ROWS - X_ROWS/4 - 5, Y_LINES/2); @@ -145,7 +148,13 @@ void SFMLBackend::update_entities() { SFMLBackend::SFMLBackend(GameEngine &g) : window(sf::VideoMode(X_DIM, Y_DIM), "Turing's Tarpit", sf::Style::None, settings), game(g) { + std::ifstream infile(".tarpit.json"); + json data = json::parse(infile); + auto audio = data["images"]; + json::string_t file_name = audio["build_works"].template get(); + face_texture.loadFromFile(file_name); + face_sprite.setTexture(face_texture); } /* diff --git a/sfmlbackend.hpp b/sfmlbackend.hpp index db28a63..e50ff0a 100644 --- a/sfmlbackend.hpp +++ b/sfmlbackend.hpp @@ -40,8 +40,8 @@ class SFMLBackend { sf::RenderWindow window; sf::Clock clock; sf::Clock deltaClock; - sf::Sprite background; - sf::Texture texture; + sf::Sprite face_sprite; + sf::Texture face_texture; bool window_active_out = false; bool show_build_log = false; int hit_points = 50; diff --git a/status.txt b/status.txt index 0dc11aa..d9c4c58 100644 --- a/status.txt +++ b/status.txt @@ -2,9 +2,15 @@ BUGS: +* Better error handling on config json. + TODO: * Add a timer to the game engine so you can set a kind of pomodoro timer and if you don't meet the goal it costs you. * Convert buttons to sprites. * Mouse events to the GUI. * sf::Rect::contains(mouse.x, mouse.y) will say if the mouse is inside the sprite rect. + +NOTES: + +Pic is 240x240 diff --git a/tarpit_sample.json b/tarpit_sample.json index 1e67401..41c6611 100644 --- a/tarpit_sample.json +++ b/tarpit_sample.json @@ -5,6 +5,9 @@ "build_failed": "./assets/build_failed.mp3", "building": "./assets/building.mp3" }, + "images": { + "build_words": "./assets/build_success.png" + }, "git_path": ".\\", "build_cmd": "meson compile -C builddir" }