Use pointers for the stuff so it can lazy load.
This commit is contained in:
parent
f5f8cdba37
commit
10ecf50bc0
2 changed files with 9 additions and 20 deletions
|
@ -136,13 +136,6 @@ void SFMLBackend::update_entities() {
|
|||
|
||||
string time = fmt::format("{:%H:%M:%OS}", elapsed_time);
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -161,18 +154,15 @@ SFMLBackend::SFMLBackend(GameEngine &g)
|
|||
: window(sf::VideoMode({X_DIM, Y_DIM}), "Turing's Tarpit"),
|
||||
game(g)
|
||||
{
|
||||
face_texture = make_shared<sf::Texture>("./assets/building.png");
|
||||
stop_texture = make_shared<sf::Texture>("./assets/stop_button.png");
|
||||
start_texture = make_shared<sf::Texture>("./assets/start_button.png");
|
||||
std::ifstream infile(".tarpit.json");
|
||||
json data = json::parse(infile);
|
||||
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);
|
||||
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.
|
||||
*
|
||||
|
@ -189,8 +179,11 @@ void SFMLBackend::update_log(std::vector<string> &lines) {
|
|||
|
||||
void SFMLBackend::startup() {
|
||||
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.");
|
||||
}
|
||||
|
||||
|
|
|
@ -51,10 +51,6 @@ class SFMLBackend {
|
|||
sf::RenderWindow window;
|
||||
std::shared_ptr<sf::Sprite> face_sprite = nullptr;
|
||||
std::shared_ptr<sf::Texture> face_texture = nullptr;
|
||||
std::shared_ptr<sf::Sprite> stop_button = nullptr;
|
||||
std::shared_ptr<sf::Texture> stop_texture = nullptr;
|
||||
std::shared_ptr<sf::Sprite> start_button = nullptr;
|
||||
std::shared_ptr<sf::Texture> start_texture = nullptr;
|
||||
std::chrono::time_point<std::chrono::system_clock> clock_start;
|
||||
Button buttons = Button::STOP;
|
||||
int hit_points = 50;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue