From af2947c50a91e47a84a0f9884f9a8aa6b6705d01 Mon Sep 17 00:00:00 2001
From: "Zed A. Shaw" <zed.shaw@gmail.com>
Date: Sun, 25 May 2025 12:12:08 -0400
Subject: [PATCH] Simple styling of the rooms done.

---
 assets/tiles.json |  2 +-
 map.cpp           |  4 ----
 map.hpp           |  3 ++-
 worldbuilder.cpp  | 12 ++++++++++++
 worldbuilder.hpp  |  1 +
 5 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/assets/tiles.json b/assets/tiles.json
index 8ca54de..29aa5cd 100644
--- a/assets/tiles.json
+++ b/assets/tiles.json
@@ -21,7 +21,7 @@
     "background": [230, 20, 120],
     "collision": true,
     "display": 8820,
-    "id": 3
+    "id": 2
   },
   "WALL_VINES": {
     "texture": "assets/wall_with_vines-256.png",
diff --git a/map.cpp b/map.cpp
index 52e3e9a..66c8dd9 100644
--- a/map.cpp
+++ b/map.cpp
@@ -146,10 +146,6 @@ void Map::init_tiles() {
   $tiles = $walls;
 }
 
-Matrix& Map::tiles() {
-  return $walls;
-}
-
 void Map::enclose() {
   // wraps the outside edge with solid walls
   std::array<Point, 4> starts{{
diff --git a/map.hpp b/map.hpp
index fd00998..dc5f1fa 100644
--- a/map.hpp
+++ b/map.hpp
@@ -37,6 +37,8 @@ public:
   Matrix& paths() { return $paths.paths(); }
   Matrix& input_map() { return $paths.input(); }
   Matrix& walls() { return $walls; }
+  Matrix& tiles() { return $tiles; }
+  std::vector<Room>& rooms() { return $rooms; }
   size_t width() { return $width; }
   size_t height() { return $height; }
   int distance(Point to) { return $paths.distance(to); }
@@ -64,7 +66,6 @@ public:
   bool INVARIANT();
 
   void init_tiles();
-  Matrix& tiles();
   void add_room(Room &room);
   void invert_space();
 };
diff --git a/worldbuilder.cpp b/worldbuilder.cpp
index dab3d29..aa8acda 100644
--- a/worldbuilder.cpp
+++ b/worldbuilder.cpp
@@ -21,6 +21,16 @@ void big_donut() {
   // maze.hunt_and_kill({11,11});
 }
 
+void WorldBuilder::stylize_rooms() {
+  auto& tiles = $map.tiles();
+
+  for(auto& room : $map.rooms()) {
+    for(matrix::box it{tiles, room.x, room.y, room.width+1, room.height+1}; it.next();) {
+      if(tiles[it.y][it.x] == 1) tiles[it.y][it.x] = 2;
+    }
+  }
+}
+
 void WorldBuilder::generate_map() {
   maze::Builder maze($map);
 
@@ -37,6 +47,8 @@ void WorldBuilder::generate_map() {
 
   $map.enclose();
   $map.init_tiles();
+
+  stylize_rooms();
 }
 
 bool WorldBuilder::find_open_spot(Point& pos_out) {
diff --git a/worldbuilder.hpp b/worldbuilder.hpp
index bb5663e..588fbd7 100644
--- a/worldbuilder.hpp
+++ b/worldbuilder.hpp
@@ -28,4 +28,5 @@ class WorldBuilder {
   void randomize_entities(DinkyECS::World &world, components::GameConfig &config);
   void place_stairs(DinkyECS::World& world, components::GameConfig& config);
   void configure_starting_items(DinkyECS::World &world);
+  void stylize_rooms();
 };