@2d-game-grid/square
Version:
A simple square grid made for games
36 lines (35 loc) • 918 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SquareEdges = void 0;
const core_1 = require("@2d-game-grid/core");
class SquareEdges extends core_1.Edges {
grid;
cell;
constructor(grid, cell) {
super(grid, cell);
this.grid = grid;
this.cell = cell;
}
findNeighbor(direction) {
return this.cell.neighbors.find(direction);
}
getPreviousEdgeDirection(direction) {
const directions = {
TOP: 'LEFT',
RIGHT: 'TOP',
BOTTOM: 'RIGHT',
LEFT: 'BOTTOM',
};
return directions[direction];
}
getNextEdgeDirection(direction) {
const directions = {
TOP: 'RIGHT',
RIGHT: 'BOTTOM',
BOTTOM: 'LEFT',
LEFT: 'TOP',
};
return directions[direction];
}
}
exports.SquareEdges = SquareEdges;