Intermediate refactor to move everything over to using the textures module rather than everyone using one TexturePack thing.
parent
6c1d851e85
commit
f3e1413022
@ -0,0 +1,17 @@ |
||||
#include <catch2/catch_test_macros.hpp> |
||||
#include <fmt/core.h> |
||||
#include <string> |
||||
#include "textures2.hpp" |
||||
|
||||
using namespace fmt; |
||||
|
||||
TEST_CASE("test texture management", "[textures]") { |
||||
|
||||
textures::init(); |
||||
auto spider = textures::get("hairy_spider"); |
||||
|
||||
auto image = textures::load_image("assets/hairy_spider-256.png"); |
||||
|
||||
auto img_ptr = textures::get_surface(0); |
||||
REQUIRE(img_ptr != nullptr); |
||||
} |
@ -0,0 +1,38 @@ |
||||
#include "textures2.hpp" |
||||
|
||||
namespace textures { |
||||
static TextureManager textures; |
||||
static bool initialized = false; |
||||
|
||||
void init() { |
||||
if(!initialized) { |
||||
textures.load_tiles(); |
||||
textures.load_sprites(); |
||||
initialized = true; |
||||
} |
||||
} |
||||
|
||||
SpriteTexture get(std::string name) { |
||||
return textures.get(name); |
||||
} |
||||
|
||||
sf::Image load_image(std::string filename) { |
||||
return textures.load_image(filename); |
||||
} |
||||
|
||||
const uint32_t* get_surface(size_t num) { |
||||
return textures.get_surface(num); |
||||
} |
||||
|
||||
matrix::Matrix convert_char_to_texture(matrix::Matrix &from) { |
||||
return textures.convert_char_to_texture(from); |
||||
} |
||||
|
||||
const uint32_t* get_floor() { |
||||
return (const uint32_t *)textures.floor.getPixelsPtr(); |
||||
} |
||||
|
||||
const uint32_t* get_ceiling() { |
||||
return (const uint32_t *)textures.ceiling.getPixelsPtr(); |
||||
} |
||||
}; |
@ -0,0 +1,18 @@ |
||||
#pragma once |
||||
#include "texture.hpp" |
||||
|
||||
namespace textures { |
||||
void init(); |
||||
|
||||
SpriteTexture get(std::string name); |
||||
|
||||
sf::Image load_image(std::string filename); |
||||
|
||||
const uint32_t* get_surface(size_t num); |
||||
|
||||
matrix::Matrix convert_char_to_texture(matrix::Matrix &from); |
||||
|
||||
const uint32_t* get_floor(); |
||||
|
||||
const uint32_t* get_ceiling(); |
||||
} |
Loading…
Reference in new issue