First cut of pulling out the relevant parts of my original game to make a little framework.
This commit is contained in:
commit
6a0c9e8d46
177 changed files with 18197 additions and 0 deletions
56
src/graphics/textures.hpp
Normal file
56
src/graphics/textures.hpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <SFML/Graphics/Sprite.hpp>
|
||||
#include <SFML/Graphics/Image.hpp>
|
||||
#include <SFML/Graphics/Texture.hpp>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include "algos/matrix.hpp"
|
||||
|
||||
namespace textures {
|
||||
|
||||
struct SpriteTexture {
|
||||
std::shared_ptr<sf::Sprite> sprite = nullptr;
|
||||
std::shared_ptr<sf::Texture> texture = nullptr;
|
||||
sf::Vector2i frame_size;
|
||||
};
|
||||
|
||||
using SpriteTextureMap = std::unordered_map<std::string, SpriteTexture>;
|
||||
|
||||
struct TextureManager {
|
||||
std::vector<sf::Image> surfaces;
|
||||
std::vector<size_t> ceilings;
|
||||
std::vector<wchar_t> map_tile_set;
|
||||
std::vector<int> ambient_light;
|
||||
SpriteTextureMap sprite_textures;
|
||||
SpriteTextureMap icon_textures;
|
||||
std::unordered_map<std::string, size_t> name_to_id;
|
||||
std::unordered_map<wchar_t, sf::Sprite> map_sprites;
|
||||
sf::Texture map_sprite_sheet{"./assets/map_tiles.png"};
|
||||
};
|
||||
|
||||
void init();
|
||||
|
||||
SpriteTexture get_sprite(const std::string& name, bool duped=false);
|
||||
SpriteTexture get_icon(const std::string& name);
|
||||
|
||||
sf::Image load_image(const std::string& filename);
|
||||
|
||||
std::vector<int>& get_ambient_light();
|
||||
|
||||
std::vector<wchar_t>& get_map_tile_set();
|
||||
|
||||
const uint32_t* get_surface(size_t num);
|
||||
|
||||
sf::Image& get_surface_img(size_t num);
|
||||
|
||||
const uint32_t* get_ceiling(size_t num);
|
||||
|
||||
sf::Sprite& get_map_sprite(wchar_t display);
|
||||
|
||||
size_t get_id(const std::string& name);
|
||||
|
||||
size_t door_for_wall(size_t wall_id);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue