diff --git a/assets/tiles.json b/assets/tiles.json index d657b7b..3b6c226 100644 --- a/assets/tiles.json +++ b/assets/tiles.json @@ -4,27 +4,31 @@ "foreground": [40, 15, 125], "background": [200, 15, 75], "collision": false, - "display": 10398 + "display": 10398, + "id": 0 }, "WALL_MOSS": { "texture": "assets/glowing_moss_wall-256.png", "foreground": [230, 20, 30], "background": [230, 20, 120], "collision": true, - "display": 8820 + "display": 8820, + "id": 1 }, "WALL_PLAIN": { "texture": "assets/wall_texture_test-256.png", "foreground": [230, 20, 30], "background": [230, 20, 120], "collision": true, - "display": 9608 + "display": 9608, + "id": 2 }, "WALL_VINES": { "texture": "assets/wall_with_vines-256.png", "foreground": [230, 20, 30], "background": [230, 20, 120], "collision": false, - "display": 35 + "display": 35, + "id": 3 } } diff --git a/map.cpp b/map.cpp index d008941..e2dbfc5 100644 --- a/map.cpp +++ b/map.cpp @@ -149,6 +149,7 @@ void Map::load_tiles() { } void Map::enclose() { + // wraps the outside edge with solid walls std::array starts{{ {0,0}, {$width-1, 0}, {$width-1, $height-1}, {0, $height-1} }}; diff --git a/raycaster.cpp b/raycaster.cpp index 16b04e4..055f4f6 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -383,6 +383,8 @@ void Raycaster::draw_ceiling_floor() { int map_y = int(floor_y); int light_level = matrix::inbounds(lights, map_x, map_y) ? lights[map_y][map_x] : 30; + // NOTE: use map_x/y to get the floor, ceiling texture. + // FLOOR color = $floor_texture[texture_width * ty + tx]; $pixels[pixcoord(x, y)] = lighting_calc(color, row_distance, light_level); diff --git a/tilemap.cpp b/tilemap.cpp index 94ae667..80b0879 100644 --- a/tilemap.cpp +++ b/tilemap.cpp @@ -38,8 +38,8 @@ void TileMap::dump(int show_x, int show_y) { std::cout << to_string(show_x, show_y) << std::endl; } -void TileMap::set_tile(size_t x, size_t y, string tile_name) { - json tile_conf = $config[tile_name]; +void TileMap::set_tile(size_t x, size_t y, const string& tile_name) { + json& tile_conf = $config[tile_name]; auto tile = components::convert(tile_conf); $tile_ids[y][x] = tile.display; diff --git a/tilemap.hpp b/tilemap.hpp index e8312c6..b450da4 100644 --- a/tilemap.hpp +++ b/tilemap.hpp @@ -28,8 +28,8 @@ public: size_t width() { return $width; } size_t height() { return $height; } void load(matrix::Matrix &walls); - const components::Tile &at(size_t x, size_t y); - void set_tile(size_t x, size_t y, std::string tile_name); + const components::Tile& at(size_t x, size_t y); + void set_tile(size_t x, size_t y, const std::string& tile_name); std::vector tile_names(bool collision); std::string to_string(int show_x, int show_y);