|
|
@ -136,13 +136,6 @@ void SFMLBackend::update_entities() { |
|
|
|
|
|
|
|
|
|
|
|
string time = fmt::format("{:%H:%M:%OS}", elapsed_time); |
|
|
|
string time = fmt::format("{:%H:%M:%OS}", elapsed_time); |
|
|
|
write_text(7, 14, time, 2.0f); |
|
|
|
write_text(7, 14, time, 2.0f); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop_button->setPosition(translate(27, 15)); |
|
|
|
|
|
|
|
window.draw(*start_button); |
|
|
|
|
|
|
|
start_button->setPosition(translate(37, 15)); |
|
|
|
|
|
|
|
window.draw(*stop_button); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Window_update(); |
|
|
|
Window_update(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -161,18 +154,15 @@ SFMLBackend::SFMLBackend(GameEngine &g) |
|
|
|
: window(sf::VideoMode({X_DIM, Y_DIM}), "Turing's Tarpit"), |
|
|
|
: window(sf::VideoMode({X_DIM, Y_DIM}), "Turing's Tarpit"), |
|
|
|
game(g) |
|
|
|
game(g) |
|
|
|
{ |
|
|
|
{ |
|
|
|
face_texture = make_shared<sf::Texture>("./assets/building.png"); |
|
|
|
std::ifstream infile(".tarpit.json"); |
|
|
|
stop_texture = make_shared<sf::Texture>("./assets/stop_button.png"); |
|
|
|
json data = json::parse(infile); |
|
|
|
start_texture = make_shared<sf::Texture>("./assets/start_button.png"); |
|
|
|
auto images = data["images"]; |
|
|
|
|
|
|
|
std::string build_name = images["building"]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face_texture = make_shared<sf::Texture>(build_name); |
|
|
|
face_sprite = make_shared<sf::Sprite>(*face_texture); |
|
|
|
face_sprite = make_shared<sf::Sprite>(*face_texture); |
|
|
|
stop_button = make_shared<sf::Sprite>(*stop_texture); |
|
|
|
|
|
|
|
start_button = make_shared<sf::Sprite>(*start_texture); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
change_face("building"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* This makes my soul hurt. Make it stop. |
|
|
|
* This makes my soul hurt. Make it stop. |
|
|
|
* |
|
|
|
* |
|
|
@ -189,8 +179,11 @@ void SFMLBackend::update_log(std::vector<string> &lines) { |
|
|
|
|
|
|
|
|
|
|
|
void SFMLBackend::startup() { |
|
|
|
void SFMLBackend::startup() { |
|
|
|
fmt::print("Setting up a window for you...\n"); |
|
|
|
fmt::print("Setting up a window for you...\n"); |
|
|
|
|
|
|
|
std::ifstream infile(".tarpit.json"); |
|
|
|
|
|
|
|
json data = json::parse(infile); |
|
|
|
|
|
|
|
std::string font_file = data["font"]; |
|
|
|
|
|
|
|
|
|
|
|
if(!font.openFromFile("./assets/text.ttf")) { |
|
|
|
if(!font.openFromFile(font_file)) { |
|
|
|
fmt::println("Cannot load font."); |
|
|
|
fmt::println("Cannot load font."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|