diff --git a/systems.cpp b/systems.cpp index 12f527f..7d48519 100644 --- a/systems.cpp +++ b/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(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(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' '; + } } diff --git a/textures.cpp b/textures.cpp index 37b90a0..6037faf 100644 --- a/textures.cpp +++ b/textures.cpp @@ -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& get_tile_set() { + return TMGR.tile_set; + } + const uint32_t* get_surface(size_t num) { return (const uint32_t *)TMGR.surfaces[num].getPixelsPtr(); } diff --git a/textures.hpp b/textures.hpp index aaef349..ff4a36b 100644 --- a/textures.hpp +++ b/textures.hpp @@ -16,6 +16,7 @@ namespace textures { struct TextureManager { std::vector surfaces; + std::vector tile_set; std::unordered_map sprite_textures; sf::Image floor; sf::Image ceiling; @@ -27,6 +28,8 @@ namespace textures { sf::Image load_image(const std::string& filename); + std::vector& get_tile_set(); + const uint32_t* get_surface(size_t num); const uint32_t* get_floor(); diff --git a/worldbuilder.cpp b/worldbuilder.cpp index aa8acda..4feaa11 100644 --- a/worldbuilder.cpp +++ b/worldbuilder.cpp @@ -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();