Graveyard terrain and background tiles implemented

This commit is contained in:
Mal
2025-05-16 23:08:35 +02:00
parent e97c04ed19
commit fc990c12aa
25 changed files with 504 additions and 50 deletions

View File

@@ -3,41 +3,74 @@ import Setting from "../../js/Setting.js";
export default class Tileset
{
/**
* @param {number} setId
*/
constructor(setId)
{
/** @type {number} */
this.setId = setId;
/** @type {Image} */
this.image = new Image();
this.image.src = '../' + Setting.TILESET_LOCATION + GraphicSet[this.setId].tileset;
/** @type {number} */
this.tiles = GraphicSet[this.setId].tiles;
/** @type {number} */
this.scale = GraphicSet[this.setId].scale;
/** @type {number} */
this.primaryTiles = GraphicSet[this.setId].primaryTiles;
/** @type {{image: Image, tiles: number, scale: number}|null} */
this.background = null;
if (GraphicSet[this.setId].tilesetBackground !== null) {
const backgroundImage = new Image();
backgroundImage.src = '../' + Setting.TILESET_LOCATION +
GraphicSet[this.setId].tilesetBackground.path;
this.background = {
image: backgroundImage,
tiles: GraphicSet[this.setId].tilesetBackground.tiles,
scale: GraphicSet[this.setId].tilesetBackground.scale,
};
}
}
/** @returns {number} */
getWidth()
{
return this.image.width * this.scale;
}
/** @returns {number} */
getHeight()
{
return this.image.height * this.scale;
}
/** @returns {number} */
getTileWidth()
{
return this.image.width / this.tiles * this.scale;
}
/** @returns {number} */
getTileHeight()
{
return this.image.height * this.scale;
}
/** @returns {boolean} */
hasExtendedTiles()
{
return GraphicSet[this.setId].tiles > GraphicSet[this.setId].primaryTiles ;
}
/** @returns {number} */
getTileIndexFactor(code)
{
const CODES = ['ltr', 't', 'r', 'b', 'l', 'lt', 'tr', 'ltb', 'tb', 'trb', 'lb', 'rb', 'ltrb', 'lr', 'lrb'];