Skip to content

Commit 729eef6

Browse files
author
Josh Lory
authored
Merge pull request #15 from code-dot-org/solid-inner-corner-walls
Ensure inner corners get a solid wall tile, not a randomized one
2 parents f2755a8 + 4370978 commit 729eef6

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
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/beeCell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @overview BeeCell represents the contets of the grid elements for Bee.
2+
* @overview BeeCell represents the contents of the grid elements for Bee.
33
* Bee BeeCells are more complex than many other kinds of cell; they can be
44
* "hidden" with clouds, they can represent multiple different kinds of
55
* element (flower, hive), some of which can be multiple colors (red,

src/subtype.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const Cell = require('./cell')
2-
const DirtDrawer = require('./dirtDrawer')
1+
const Cell = require('./cell');
2+
const DirtDrawer = require('./dirtDrawer');
33

44
const SquareType = require('./tiles').SquareType;
55
const EventEmitter = require('events').EventEmitter; // provided by webpack's node-libs-browser
@@ -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 {
@@ -149,11 +152,6 @@ module.exports = class Subtype extends EventEmitter {
149152
tile = 'null' + wallIdx;
150153
}
151154

152-
// For the first 3 levels in maze, only show the null0 image.
153-
if (['2_1', '2_2', '2_3'].includes(this.level_.id)) {
154-
this.wallMap[y][x] = 0;
155-
tile = 'null0';
156-
}
157155
return tile;
158156
}
159157

@@ -172,12 +170,14 @@ module.exports = class Subtype extends EventEmitter {
172170
this.isOnPathStr_(col, row + 1) + // South.
173171
this.isOnPathStr_(col - 1, row); // East.
174172

175-
const adjacentToPath = (tile !== '00000');
176-
177173
// Draw the tile.
178174
if (!TILE_SHAPES[tile]) {
175+
const adjacentToPath = tile !== '00000';
176+
// Any block with 2, 3 or 4 orthogonal paths.
177+
const innerCorner = adjacentToPath && tile.split('1').length > 2;
178+
179179
// We have an empty square. Handle it differently based on skin.
180-
tile = this.getEmptyTile(col, row, adjacentToPath);
180+
tile = this.getEmptyTile(col, row, adjacentToPath, innerCorner);
181181
}
182182

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

0 commit comments

Comments
 (0)