about summary refs log tree commit diff
path: root/src/level_gen/util.rs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-07-28T21·45-0400
committerGriffin Smith <root@gws.fyi>2019-07-28T21·45-0400
commit6c1eba67629504f10fa08ee68fb31f507c99b0d1 (patch)
treed5af8f3eb6dc32a1308a20863e5c8814a4634098 /src/level_gen/util.rs
parentf22bcad817ee354b355d29b6b289894e2d15cfaa (diff)
Allow converting generated levels to entities
Add a new Wall entity, and allow converting generated levels to entity
maps containing them, then finally displaying them using some of
the (now expanded) box drawing machinery.
Diffstat (limited to 'src/level_gen/util.rs')
-rw-r--r--src/level_gen/util.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/level_gen/util.rs b/src/level_gen/util.rs
index 629292c430fa..c9cd87309257 100644
--- a/src/level_gen/util.rs
+++ b/src/level_gen/util.rs
@@ -31,3 +31,22 @@ pub fn rand_initialize<R: Rng + ?Sized>(
     }
     ret
 }
+
+/// Fill the outer edges of a generated level with walls
+pub fn fill_outer_edges(level: &mut Vec<Vec<bool>>) {
+    let xmax = level.len();
+    if xmax == 0 {
+        return;
+    }
+    let ymax = level[0].len();
+
+    for x in 0..xmax {
+        level[x][0] = true;
+        level[x][ymax - 1] = true;
+    }
+
+    for y in 0..level[0].len() {
+        level[0][y] = true;
+        level[xmax - 1][y] = true;
+    }
+}