Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bee.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ module.exports = class Bee extends Gatherer {
/**
* @override
*/
getEmptyTile(x, y, adjacentToPath, wallMap) {
getEmptyTile(x, y, adjacentToPath) {
// begin with three trees
var tileChoices = ['null3', 'null4', 'null0'];
var noTree = 'null1';
Expand Down
2 changes: 1 addition & 1 deletion src/beeCell.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @overview BeeCell represents the contets of the grid elements for Bee.
* @overview BeeCell represents the contents of the grid elements for Bee.
* Bee BeeCells are more complex than many other kinds of cell; they can be
* "hidden" with clouds, they can represent multiple different kinds of
* element (flower, hive), some of which can be multiple colors (red,
Expand Down
24 changes: 12 additions & 12 deletions src/subtype.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Cell = require('./cell')
const DirtDrawer = require('./dirtDrawer')
const Cell = require('./cell');
const DirtDrawer = require('./dirtDrawer');

const SquareType = require('./tiles').SquareType;
const EventEmitter = require('events').EventEmitter; // provided by webpack's node-libs-browser
Expand Down Expand Up @@ -30,6 +30,9 @@ const TILE_SHAPES = {
'null4': [1, 3],
};

// Chance of showing a random wall tile other than the default.
const RANDOM_TILE_RATE = 0.2;

module.exports = class Subtype extends EventEmitter {
constructor(maze, config) {
super();
Expand Down Expand Up @@ -137,10 +140,10 @@ module.exports = class Subtype extends EventEmitter {
);
}

getEmptyTile(x, y, adjacentToPath) {
getEmptyTile(x, y, adjacentToPath, innerCorner) {
let tile;
// Empty square. Use null0 for large areas, with null1-4 for borders.
if (!adjacentToPath && Math.random() > 0.3) {
if (innerCorner || (!adjacentToPath && Math.random() > RANDOM_TILE_RATE)) {
this.wallMap[y][x] = 0;
tile = 'null0';
} else {
Expand All @@ -149,11 +152,6 @@ module.exports = class Subtype extends EventEmitter {
tile = 'null' + wallIdx;
}

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

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

const adjacentToPath = (tile !== '00000');

// Draw the tile.
if (!TILE_SHAPES[tile]) {
const adjacentToPath = tile !== '00000';
// Any block with 2, 3 or 4 orthogonal paths.
const innerCorner = adjacentToPath && tile.split('1').length > 2;

// We have an empty square. Handle it differently based on skin.
tile = this.getEmptyTile(col, row, adjacentToPath);
tile = this.getEmptyTile(col, row, adjacentToPath, innerCorner);
}

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