mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Startpoint widget implemented
This commit is contained in:
@@ -10,6 +10,8 @@ export default class Terrain
|
||||
this.fields = [];
|
||||
this.tilesX = tilesX;
|
||||
this.tilesY = tilesY;
|
||||
this.entranceTileX = undefined;
|
||||
this.entranceTileY = undefined;
|
||||
this.backgroundColor = backgroundColor;
|
||||
this.htmlElement = document.createElement('table');
|
||||
this.brushTileIndex = 0;
|
||||
@@ -62,6 +64,38 @@ export default class Terrain
|
||||
this.fields[y][x].setIndex(index);
|
||||
}
|
||||
|
||||
setEntrancePoint(tileX, tileY)
|
||||
{
|
||||
if (this.fields[tileY][tileX].index === -1) {
|
||||
if (this.entranceTileX !== undefined && this.entranceTileY !== undefined) {
|
||||
this.fields[this.entranceTileY][this.entranceTileX].setEntrancePoint(false);
|
||||
}
|
||||
|
||||
this.entranceTileX = tileX;
|
||||
this.entranceTileY = tileY;
|
||||
|
||||
this.fields[tileY][tileX].setEntrancePoint(true);
|
||||
}
|
||||
}
|
||||
|
||||
getFieldCoordinates(field)
|
||||
{
|
||||
for (let y = 0; y < this.fields.length; y++) {
|
||||
for (let x = 0; x < this.fields[y].length; x++) {
|
||||
if (this.fields[y][x] === field) {
|
||||
return {x: x, y: y};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
hasEntrancePoint()
|
||||
{
|
||||
return this.entranceTileX !== undefined && this.entranceTileY !== undefined;
|
||||
}
|
||||
|
||||
static createFromJson(json)
|
||||
{
|
||||
let terrainData = JSON.parse(json);
|
||||
|
||||
Reference in New Issue
Block a user