Fixed how sprites/textures are loaded so tehy default to frame 0 of any multi-frame textures.

This commit is contained in:
Zed A. Shaw 2025-04-05 17:17:26 -04:00
parent 6d73c87c4e
commit b832bbd78a
7 changed files with 294 additions and 70 deletions

View file

@ -15,19 +15,21 @@ namespace textures {
void load_sprites() {
Config assets("assets/config.json");
for(auto& el : assets["sprites"].items()) {
string path = el.value();
auto texture = make_shared<sf::Texture>(path);
for(auto& [name, settings] : assets["sprites"].items()) {
auto texture = make_shared<sf::Texture>(settings["path"]);
texture->setSmooth(false);
texture->setSmooth(assets["graphics"]["smooth_textures"]);
auto sprite = make_shared<sf::Sprite>(*texture);
string name = el.key();
int width = settings["frame_width"];
int height = settings["frame_height"];
sprite->setTextureRect({{0,0}, {width, height}});
TMGR.sprite_textures.try_emplace(name, name, sprite, texture);
}
TMGR.floor = load_image(assets["sprites"]["floor"]);
TMGR.ceiling = load_image(assets["sprites"]["ceiling"]);
TMGR.floor = load_image(assets["sprites"]["floor"]["path"]);
TMGR.ceiling = load_image(assets["sprites"]["ceiling"]["path"]);
}
void load_tiles() {