mirror of
https://git.leinelab.org/Mal/mr-crocs-adventures.git
synced 2025-09-11 02:57:36 +02:00
Tilorswift: Background color and fix table size.
This commit is contained in:
@@ -3,20 +3,25 @@ import Tileset from "./Tileset.js";
|
||||
|
||||
export default class Terrain
|
||||
{
|
||||
constructor(tileset, tilesX, tilesY)
|
||||
constructor(tileset, tilesX, tilesY, backgroundColor = 'black')
|
||||
{
|
||||
this.tileset = tileset;
|
||||
this.fields = [];
|
||||
this.tilesX = tilesX;
|
||||
this.tilesY = tilesY;
|
||||
this.backgroundColor = backgroundColor;
|
||||
this.htmlElement = document.createElement('table');
|
||||
this.htmlElement.id = 'level';
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
init()
|
||||
{
|
||||
this.htmlElement.id = 'level';
|
||||
this.htmlElement.style.backgroundColor = this.backgroundColor;
|
||||
this.htmlElement.style.width = this.tileset.getTileWidth() * this.tilesX + 'px';
|
||||
this.htmlElement.style.height = this.tileset.getTileHeight() * this.tilesY + 'px';
|
||||
|
||||
for (let r = 0; r < this.tilesY; r++) {
|
||||
let row = [];
|
||||
let tr = document.createElement('tr');
|
||||
@@ -51,7 +56,7 @@ export default class Terrain
|
||||
imageTileset.src = terrainData.tileset;
|
||||
|
||||
let tileset = new Tileset(imageTileset, terrainData.tiles, terrainData.scale);
|
||||
let terrain = new Terrain(tileset, terrainData.columns, terrainData.rows);
|
||||
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++) {
|
||||
|
||||
Reference in New Issue
Block a user