Skip to content

Commit 45697b6

Browse files
author
Josh Lory
committed
Ensure inner corners get a solid wall tile, not a randomized one
1 parent ca03e8d commit 45697b6

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/bee.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ module.exports = class Bee extends Gatherer {
398398
/**
399399
* @override
400400
*/
401-
getEmptyTile(x, y, adjacentToPath, wallMap) {
401+
getEmptyTile(x, y, adjacentToPath) {
402402
// begin with three trees
403403
var tileChoices = ['null3', 'null4', 'null0'];
404404
var noTree = 'null1';

src/subtype.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const TILE_SHAPES = {
3030
'null4': [1, 3],
3131
};
3232

33+
// Chance of showing a random wall tile other than the default.
34+
const RANDOM_TILE_RATE = 0.2;
35+
3336
module.exports = class Subtype extends EventEmitter {
3437
constructor(maze, config) {
3538
super();
@@ -137,10 +140,10 @@ module.exports = class Subtype extends EventEmitter {
137140
);
138141
}
139142

140-
getEmptyTile(x, y, adjacentToPath) {
143+
getEmptyTile(x, y, adjacentToPath, innerCorner) {
141144
let tile;
142145
// Empty square. Use null0 for large areas, with null1-4 for borders.
143-
if (!adjacentToPath && Math.random() > 0.3) {
146+
if (innerCorner || (!adjacentToPath && Math.random() > RANDOM_TILE_RATE)) {
144147
this.wallMap[y][x] = 0;
145148
tile = 'null0';
146149
} else {
@@ -167,12 +170,13 @@ module.exports = class Subtype extends EventEmitter {
167170
this.isOnPathStr_(col, row + 1) + // South.
168171
this.isOnPathStr_(col - 1, row); // East.
169172

170-
const adjacentToPath = (tile !== '00000');
171-
172173
// Draw the tile.
173174
if (!TILE_SHAPES[tile]) {
175+
const adjacentToPath = tile !== '00000';
176+
const innerCorner = adjacentToPath && tile.split('1').length > 2;
177+
174178
// We have an empty square. Handle it differently based on skin.
175-
tile = this.getEmptyTile(col, row, adjacentToPath);
179+
tile = this.getEmptyTile(col, row, adjacentToPath, innerCorner);
176180
}
177181

178182
this.drawTile(svg, TILE_SHAPES[tile], row, col, tileId);

0 commit comments

Comments
 (0)