|
|
|
@ -5,6 +5,8 @@ |
|
|
|
|
#include "config.hpp" |
|
|
|
|
#include "constants.hpp" |
|
|
|
|
|
|
|
|
|
using std::shared_ptr, std::make_shared; |
|
|
|
|
|
|
|
|
|
sf::Image TexturePack::load_image(std::string filename) { |
|
|
|
|
sf::Image texture; |
|
|
|
|
bool good = texture.loadFromFile(filename); |
|
|
|
@ -12,29 +14,36 @@ sf::Image TexturePack::load_image(std::string filename) { |
|
|
|
|
return texture; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TexturePack::load_textures() { |
|
|
|
|
void TexturePack::load_sprites() { |
|
|
|
|
Config assets("assets/config.json"); |
|
|
|
|
|
|
|
|
|
for(string tile_path : assets["textures"]) { |
|
|
|
|
images.emplace_back(load_image(tile_path)); |
|
|
|
|
for(auto& el : assets["sprites"].items()) { |
|
|
|
|
string path = el.value(); |
|
|
|
|
auto texture = make_shared<sf::Texture>(path); |
|
|
|
|
|
|
|
|
|
texture->setSmooth(false); |
|
|
|
|
auto sprite = make_shared<sf::Sprite>(*texture); |
|
|
|
|
|
|
|
|
|
string name = el.key(); |
|
|
|
|
sprite_textures[name] = {sprite, texture}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for(string tile_path : assets["sprites"]) { |
|
|
|
|
sword = sprite_textures["sword"]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TexturePack::position_sprite(double x, double y, string name) { |
|
|
|
|
sprites.emplace_back(x, y, sprite_textures[name]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void TexturePack::load_textures() { |
|
|
|
|
Config assets("assets/config.json"); |
|
|
|
|
|
|
|
|
|
for(string tile_path : assets["textures"]) { |
|
|
|
|
images.emplace_back(load_image(tile_path)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
floor = load_image(assets["sprites"]["floor"]); |
|
|
|
|
ceiling = load_image(assets["sprites"]["ceiling"]); |
|
|
|
|
|
|
|
|
|
sf::Texture* sprite_texture = new sf::Texture(assets["sprites"]["evil_eye"]); |
|
|
|
|
sprite_texture->setSmooth(false); |
|
|
|
|
sf::Sprite* sf_sprite = new sf::Sprite(*sprite_texture); |
|
|
|
|
|
|
|
|
|
sprites.push_back({4.0, 3.55, 6, sf_sprite, sprite_texture}); |
|
|
|
|
|
|
|
|
|
sword.sprite_texture = new sf::Texture("assets/cinqueda_1-512.png"); |
|
|
|
|
sword.sprite_texture->setSmooth(false); |
|
|
|
|
sword.sprite = new sf::Sprite(*sword.sprite_texture); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const uint32_t* TexturePack::get_texture(size_t num) { |
|
|
|
|