I can now create any tiles I want. First version is just one room will have a circular pool in it.

main
Zed A. Shaw 5 days ago
parent 89e31279be
commit 03fe9b3d01
  1. 15
      tilemap.cpp
  2. 1
      tilemap.hpp
  3. 10
      worldbuilder.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);
}
}

@ -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();

@ -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) {

Loading…
Cancel
Save