Stupid self-portrait for the game's 'bad guy'.

master
Zed A. Shaw 3 weeks ago
parent 37d28094ec
commit 3cb4fcfeb5
  1. BIN
      assets/build_success.png
  2. 2
      gui.cpp
  3. 13
      sfmlbackend.cpp
  4. 4
      sfmlbackend.hpp
  5. 6
      status.txt
  6. 3
      tarpit_sample.json

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

@ -7,8 +7,8 @@
#include <vector> #include <vector>
#include <SFML/Audio.hpp> #include <SFML/Audio.hpp>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include <fstream>
#include "builder.hpp" #include "builder.hpp"
#include <fstream>
#include <iostream> #include <iostream>
using std::string, std::vector; using std::string, std::vector;

@ -10,6 +10,8 @@
#include <SFML/Window/Event.hpp> #include <SFML/Window/Event.hpp>
#include <nlohmann/json.hpp> #include <nlohmann/json.hpp>
#include "sfmlbackend.hpp" #include "sfmlbackend.hpp"
#include <fstream>
#include <iostream>
using namespace fmt; using namespace fmt;
using namespace nlohmann; using namespace nlohmann;
@ -109,8 +111,9 @@ sf::RectangleShape SFMLBackend::box(int x, int y, int width, int height,
void SFMLBackend::update_entities() { void SFMLBackend::update_entities() {
window.clear(); window.clear();
sf::RectangleShape face_box = box(2, 2, sf::RectangleShape face_box = box(2, 2, X_ROWS/4, Y_LINES/2);
X_ROWS/4, Y_LINES/2, sf::Color(100, 250, 200)); face_sprite.setPosition(translate(2,2));
window.draw(face_sprite);
sf::RectangleShape stats_box = box(X_ROWS/4 + 4, 2, sf::RectangleShape stats_box = box(X_ROWS/4 + 4, 2,
X_ROWS - X_ROWS/4 - 5, Y_LINES/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) 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<string>();
face_texture.loadFromFile(file_name);
face_sprite.setTexture(face_texture);
} }
/* /*

@ -40,8 +40,8 @@ class SFMLBackend {
sf::RenderWindow window; sf::RenderWindow window;
sf::Clock clock; sf::Clock clock;
sf::Clock deltaClock; sf::Clock deltaClock;
sf::Sprite background; sf::Sprite face_sprite;
sf::Texture texture; sf::Texture face_texture;
bool window_active_out = false; bool window_active_out = false;
bool show_build_log = false; bool show_build_log = false;
int hit_points = 50; int hit_points = 50;

@ -2,9 +2,15 @@
BUGS: BUGS:
* Better error handling on config json.
TODO: 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. * 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. * Convert buttons to sprites.
* Mouse events to the GUI. * Mouse events to the GUI.
* sf::Rect::contains(mouse.x, mouse.y) will say if the mouse is inside the sprite rect. * sf::Rect::contains(mouse.x, mouse.y) will say if the mouse is inside the sprite rect.
NOTES:
Pic is 240x240

@ -5,6 +5,9 @@
"build_failed": "./assets/build_failed.mp3", "build_failed": "./assets/build_failed.mp3",
"building": "./assets/building.mp3" "building": "./assets/building.mp3"
}, },
"images": {
"build_words": "./assets/build_success.png"
},
"git_path": ".\\", "git_path": ".\\",
"build_cmd": "meson compile -C builddir" "build_cmd": "meson compile -C builddir"
} }

Loading…
Cancel
Save