Map is back.
This commit is contained in:
parent
af2947c50a
commit
8453e7c3b9
4 changed files with 17 additions and 16 deletions
12
systems.cpp
12
systems.cpp
|
@ -390,7 +390,7 @@ std::wstring System::draw_map(GameLevel level, size_t view_x, size_t view_y, int
|
|||
auto player_pos = world.get<Position>(level.player).location;
|
||||
Point cam_orig = map.center_camera(player_pos, view_x, view_y);
|
||||
auto &tiles = map.tiles();
|
||||
(void)tiles;
|
||||
auto &tile_set = textures::get_tile_set();
|
||||
|
||||
// make a grid of chars to work with
|
||||
auto grid = shiterator::make<wchar_t>(view_x+1, view_y+1);
|
||||
|
@ -399,11 +399,13 @@ std::wstring System::draw_map(GameLevel level, size_t view_x, size_t view_y, int
|
|||
for(shiterator::each_cell_t it{grid}; it.next();) {
|
||||
size_t tile_y = size_t(it.y) + cam_orig.y;
|
||||
size_t tile_x = size_t(it.x) + cam_orig.x;
|
||||
(void)tile_y;
|
||||
(void)tile_x;
|
||||
|
||||
// FIX ME
|
||||
grid[it.y][it.x] = 'F';
|
||||
if(matrix::inbounds(tiles, tile_x, tile_y)) {
|
||||
size_t tid = tiles[tile_y][tile_x];
|
||||
grid[it.y][it.x] = tile_set[tid];
|
||||
} else {
|
||||
grid[it.y][it.x] = L' ';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace textures {
|
|||
Config assets("assets/tiles.json");
|
||||
auto &tiles = assets.json();
|
||||
TMGR.surfaces.resize(tiles.size());
|
||||
TMGR.tile_set.resize(tiles.size());
|
||||
|
||||
for(auto &el : tiles.items()) {
|
||||
auto &config = el.value();
|
||||
|
@ -44,8 +45,10 @@ namespace textures {
|
|||
|
||||
if(surface_i >= tiles.size()) {
|
||||
TMGR.surfaces.resize(surface_i + 1);
|
||||
TMGR.tile_set.resize(surface_i + 1);
|
||||
}
|
||||
|
||||
TMGR.tile_set[surface_i] = config["display"];
|
||||
TMGR.surfaces[surface_i] = load_image(texture_fname);
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +83,10 @@ namespace textures {
|
|||
return texture;
|
||||
}
|
||||
|
||||
std::vector<wchar_t>& get_tile_set() {
|
||||
return TMGR.tile_set;
|
||||
}
|
||||
|
||||
const uint32_t* get_surface(size_t num) {
|
||||
return (const uint32_t *)TMGR.surfaces[num].getPixelsPtr();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace textures {
|
|||
|
||||
struct TextureManager {
|
||||
std::vector<sf::Image> surfaces;
|
||||
std::vector<wchar_t> tile_set;
|
||||
std::unordered_map<std::string, SpriteTexture> sprite_textures;
|
||||
sf::Image floor;
|
||||
sf::Image ceiling;
|
||||
|
@ -27,6 +28,8 @@ namespace textures {
|
|||
|
||||
sf::Image load_image(const std::string& filename);
|
||||
|
||||
std::vector<wchar_t>& get_tile_set();
|
||||
|
||||
const uint32_t* get_surface(size_t num);
|
||||
|
||||
const uint32_t* get_floor();
|
||||
|
|
|
@ -10,17 +10,6 @@
|
|||
using namespace fmt;
|
||||
using namespace components;
|
||||
|
||||
void big_donut() {
|
||||
// maze.inner_donut(12, 3);
|
||||
// $map.invert_space();
|
||||
// maze.hunt_and_kill({11,11});
|
||||
|
||||
// maze.init();
|
||||
// maze.inner_donut(12, 3);
|
||||
// $map.invert_space();
|
||||
// maze.hunt_and_kill({11,11});
|
||||
}
|
||||
|
||||
void WorldBuilder::stylize_rooms() {
|
||||
auto& tiles = $map.tiles();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue