29 lines
490 B
JavaScript
29 lines
490 B
JavaScript
export default class Tileset
|
|
{
|
|
constructor(image, tiles, scale = 1)
|
|
{
|
|
this.image = image;
|
|
this.tiles = tiles;
|
|
this.scale = scale;
|
|
}
|
|
|
|
getWidth()
|
|
{
|
|
return this.image.width * this.scale;
|
|
}
|
|
|
|
getHeight()
|
|
{
|
|
return this.image.height * this.scale;
|
|
}
|
|
|
|
getTileWidth()
|
|
{
|
|
return this.image.width / this.tiles * this.scale;
|
|
}
|
|
|
|
getTileHeight()
|
|
{
|
|
return this.image.height * this.scale;
|
|
}
|
|
} |