mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Camera implemented.
This commit is contained in:
@@ -48,6 +48,16 @@ export default class Terrain
|
||||
return this.tileset;
|
||||
}
|
||||
|
||||
getWidth()
|
||||
{
|
||||
return this.tilesX * this.tilest.getTileWidth();
|
||||
}
|
||||
|
||||
getHeight()
|
||||
{
|
||||
return this.tilesY * this.tilest.getTileHeight();
|
||||
}
|
||||
|
||||
addRows(index, quantity = 1)
|
||||
{
|
||||
for (let q = 0; q < quantity; q++) {
|
||||
@@ -70,6 +80,8 @@ export default class Terrain
|
||||
tr.appendChild(td);
|
||||
}
|
||||
|
||||
console.log(row.length);
|
||||
|
||||
if (index === undefined || index >= this.tilesY - 1) {
|
||||
this.fields.push(row);
|
||||
this.htmlElement.appendChild(tr);
|
||||
@@ -142,18 +154,21 @@ export default class Terrain
|
||||
return this.entranceTileX !== undefined && this.entranceTileY !== undefined;
|
||||
}
|
||||
|
||||
static createFromJson(json)
|
||||
static createFromJson(terrainData)
|
||||
{
|
||||
let terrainData = JSON.parse(json);
|
||||
let imageTileset = new Image();
|
||||
imageTileset.src = terrainData.tileset;
|
||||
|
||||
let tileset = new Tileset(imageTileset, terrainData.tiles, terrainData.scale);
|
||||
let terrain = new Terrain(tileset, terrainData.columns, terrainData.rows, terrainData.backgroundColor);
|
||||
|
||||
for (let y = 0; y < terrainData.matrix.length; y++) {
|
||||
for (let x = 0; x < terrainData.matrix[y].length; x++) {
|
||||
for (let y = 0; y < terrainData.rows; y++) {
|
||||
for (let x = 0; x < terrainData.columns; x++) {
|
||||
terrain.setFieldIndex(x, y, terrainData.matrix[y][x]);
|
||||
|
||||
if (x === terrainData.startX && y === terrainData.startY) {
|
||||
terrain.setEntrancePoint(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user