Skip to content

Commit

Permalink
Merge pull request #16 from w4ffl35/feature-ability-to-choose-ascendi…
Browse files Browse the repository at this point in the history
…ng-descending-stairs

Feature ability to choose ascending descending stairs
  • Loading branch information
w4ffl35 authored Sep 3, 2022
2 parents c2ebe88 + 9aeb6ad commit 3a3fd45
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Use the `src.generators.stairs` generator to connect the floors with stairs.
█░██░░░░░██░░░░░░░░░█
█░███░█░███░░░░░█░█░█
█░░░█░█░░░░░█░░░█░█░█
████░█░█████████░█░█
████░█░█████████░█░█
█░░░█░█░░░█░░░░░█░███
█░███░███░█░███░█░███
█░█░░░░██░█░█░░░█░░░█
Expand All @@ -155,7 +155,7 @@ Use the `src.generators.stairs` generator to connect the floors with stairs.
█░░░░░░░░░█░░░░░░░░██
██░░░░░░░░█░█████░███
█░░░░░░░░░░░█░░██░░░█
█░░░░░░░░█░█░█████░█
█░░░░░░░░█░█░█████░█
█░░░░░░░░░█░░░█░░░█░█
█░░░░░░░░░█████░█░█░█
███░░░░██░░░░░░░█░░░█
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-maze-generator",
"version": "1.4.2",
"version": "1.4.3",
"description": "Generate perfect mazes with Node using a growing tree algorithm",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/generators/stairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class StairsGenerator {
constructor(data, options) {
this.data = data||{};
this.options = options||{ascending: true};
this.options = options||{ascending: false};
this.max_stairs = options.max_stairs || 1;
this.generate();
}
Expand Down
12 changes: 9 additions & 3 deletions src/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ class Renderer {
for (let y = 0; y < generator.data.grid.height; y++) {
let row = '';
for (let x = 0; x < generator.data.grid.width; x++) {
let f = generator.data.grid.cells[z][y][x].blocked ? '\u2588' : '\u2591';
if (generator.data.grid.cells[z][y][x].stairs) {
f = '\u2699';
let cell = generator.data.grid.cells[z][y][x];
let f = cell.blocked ? '\u2588' : '\u2591';
if (cell.stairs) {
if (cell.stairs.direction === 'up') {
f = '\u25B2';
}
else {
f = '\u25BC';
}
}
row += f;
}
Expand Down

0 comments on commit 3a3fd45

Please sign in to comment.