27 lines
No EOL
525 B
JavaScript
27 lines
No EOL
525 B
JavaScript
function TileEngine() {
|
|
this.tileSize = 32;
|
|
|
|
this.tileGroups = {
|
|
blocking: [
|
|
2, 3, 4
|
|
]
|
|
};
|
|
}
|
|
|
|
/*
|
|
* Checks to see if a tile ID is
|
|
* blocking (can't be walked through)
|
|
**/
|
|
TileEngine.prototype.isBlocking = function(tileID) {
|
|
if (this.tileGroups.blocking.indexOf(tileID) > -1) {
|
|
return true;
|
|
} else return false;
|
|
}
|
|
|
|
function tilePosToCellPos(tilePos) {
|
|
return [Math.floor(tilePos / level.height), tilePos % level.width];
|
|
}
|
|
|
|
function cellPosToTilePos(cellPos) {
|
|
return (cellPos[0] * level.width) + cellPos[1];
|
|
} |