Move amt's examples into scratchpad for later review.
This commit is contained in:
parent
9c02fb846b
commit
a4a4389281
8 changed files with 1847 additions and 0 deletions
34
scratchpad/amt/texture.cpp
Normal file
34
scratchpad/amt/texture.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#include <SFML/Graphics/Image.hpp>
|
||||
#include "dbc.hpp"
|
||||
#include <fmt/core.h>
|
||||
#include "config.hpp"
|
||||
#include "amt/texture.hpp"
|
||||
|
||||
Image TexturePack::load_image(std::string filename) {
|
||||
sf::Image img;
|
||||
bool good = img.loadFromFile(filename);
|
||||
dbc::check(good, format("failed to load {}", filename));
|
||||
return amt::PixelBuf(img.getPixelsPtr(), TEXTURE_HEIGHT, TEXTURE_WIDTH);
|
||||
}
|
||||
|
||||
void TexturePack::load_textures() {
|
||||
Config assets("assets/config.json");
|
||||
for(string tile_path : assets["textures"]) {
|
||||
images.emplace_back(load_image(tile_path));
|
||||
}
|
||||
|
||||
for(string tile_path : assets["sprites"]) {
|
||||
images.emplace_back(load_image(tile_path));
|
||||
}
|
||||
|
||||
floor = load_image(assets["floor"]);
|
||||
ceiling = load_image(assets["ceiling"]);
|
||||
}
|
||||
|
||||
Image& TexturePack::get_texture(size_t num) {
|
||||
return images[num];
|
||||
}
|
||||
|
||||
Sprite &TexturePack::get_sprite(size_t sprite_num) {
|
||||
return sprites[sprite_num];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue