Now I have a better error that's more exact, but I think next level of this is to just show a generic texture for missing ones. Closes #80.
This commit is contained in:
parent
25a143cf22
commit
ae1a48deed
2 changed files with 5 additions and 2 deletions
|
@ -311,7 +311,6 @@ void System::collision(GameLevel &level) {
|
||||||
void System::remove_from_world(GameLevel &level, Entity entity) {
|
void System::remove_from_world(GameLevel &level, Entity entity) {
|
||||||
auto& item_pos = level.world->get<Position>(entity);
|
auto& item_pos = level.world->get<Position>(entity);
|
||||||
level.collision->remove(item_pos.location, entity);
|
level.collision->remove(item_pos.location, entity);
|
||||||
// level.world->remove<Tile>(entity);
|
|
||||||
// if you don't do this you get the bug that you can pickup
|
// if you don't do this you get the bug that you can pickup
|
||||||
// an item and it'll also be in your inventory
|
// an item and it'll also be in your inventory
|
||||||
level.world->remove<Position>(entity);
|
level.world->remove<Position>(entity);
|
||||||
|
|
|
@ -5,16 +5,20 @@
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace textures {
|
namespace textures {
|
||||||
using std::shared_ptr, std::make_shared, nlohmann::json, std::string;
|
using std::shared_ptr, std::make_shared, nlohmann::json, std::string;
|
||||||
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
static TextureManager TMGR;
|
static TextureManager TMGR;
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
|
|
||||||
void load_sprite_textures(SpriteTextureMap &mapping, json &config, bool smooth) {
|
void load_sprite_textures(SpriteTextureMap &mapping, json &config, bool smooth) {
|
||||||
for(auto& [name, settings] : config.items()) {
|
for(auto& [name, settings] : config.items()) {
|
||||||
auto texture = make_shared<sf::Texture>(settings["path"]);
|
const string& path = settings["path"];
|
||||||
|
dbc::check(fs::exists(path), fmt::format("texture at {} doesn't exist", path));
|
||||||
|
auto texture = make_shared<sf::Texture>(path);
|
||||||
|
|
||||||
texture->setSmooth(smooth);
|
texture->setSmooth(smooth);
|
||||||
auto sprite = make_shared<sf::Sprite>(*texture);
|
auto sprite = make_shared<sf::Sprite>(*texture);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue