From 03fe9b3d013651ce67d104f9ec2315eb97d9ce2e Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Tue, 24 Dec 2024 03:26:06 -0500 Subject: [PATCH] I can now create any tiles I want. First version is just one room will have a circular pool in it. --- tilemap.cpp | 15 +++++++++------ tilemap.hpp | 1 + worldbuilder.cpp | 10 +++++++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tilemap.cpp b/tilemap.cpp index 44a5763..b65ef59 100644 --- a/tilemap.cpp +++ b/tilemap.cpp @@ -30,10 +30,7 @@ void TileMap::dump(int show_x, int show_y) { } } -void TileMap::load(matrix::Matrix &walls) { - for(matrix::each_cell it{walls}; it.next();) { - string tile_name = walls[it.y][it.x] == SPACE_VALUE ? "FLOOR_TILE" : "WALL_TILE"; - +void TileMap::set_tile(size_t x, size_t y, string tile_name) { std::wstring tile_id = $config.wstring(tile_name, "display"); json tile_conf = $config[tile_name]; TileCell tile{ @@ -45,8 +42,14 @@ void TileMap::load(matrix::Matrix &walls) { tile_conf["background"][1], tile_conf["background"][2]}; - $tile_ids[it.y][it.x] = tile_id[0]; - $display[it.y][it.x] = tile; + $tile_ids[y][x] = tile_id[0]; + $display[y][x] = tile; +} + +void TileMap::load(matrix::Matrix &walls) { + for(matrix::each_cell it{walls}; it.next();) { + string tile_name = walls[it.y][it.x] == SPACE_VALUE ? "FLOOR_TILE" : "WALL_TILE"; + set_tile(it.x, it.y, tile_name); } } diff --git a/tilemap.hpp b/tilemap.hpp index a4e210e..3567b54 100644 --- a/tilemap.hpp +++ b/tilemap.hpp @@ -39,6 +39,7 @@ public: size_t height() { return $height; } void load(matrix::Matrix &walls); const TileCell &at(size_t x, size_t y); + void set_tile(size_t x, size_t y, std::string tile_name); void dump(int show_x=-1, int show_y=-1); bool INVARIANT(); diff --git a/worldbuilder.cpp b/worldbuilder.cpp index 518dda8..81d0564 100644 --- a/worldbuilder.cpp +++ b/worldbuilder.cpp @@ -139,8 +139,16 @@ void WorldBuilder::generate() { $map.$walls[it.y][it.x] = is_wall; } - // BUG: this is so weird $map.load_tiles(); + + Point center = $map.place_entity(1); + for(matrix::circle it{center, 3}; it.next();) { + for(int x = it.x0; x < it.x1; x++) { + if($map.inmap(x, it.y) && !$map.iswall(x, it.y)) { + $map.$tiles.set_tile(x, it.y, "WATER_TILE"); + } + } + } } void WorldBuilder::make_room(size_t origin_x, size_t origin_y, size_t w, size_t h) {