Closed luizbills closed 2 years ago
@luizbills, there was quite some discussion about this back in 2013 when we added this feature: https://github.com/ondras/rot.js/issues/20
Please see this post in particular, where I initially went with the "grid position" approach but reverted to absolute numbers after hearing user feedback and deciding absolute pixels are better.
So... I think we could add support to gutter/padding and return to using grid positions?
var displayOptions = {
// ...
tileSetPadding: 4,
tileSetGutter: 1,
tileMap: {
"@": [0, 0],
"#": [0, 1],
"a": [1, 0],
"!": [1, 1] // grid position
}
// ...
}
Support to "atlas" would be great too.
I have an idea to maintain compatibility.
var displayOptions = {
tileMap: {
// type: "absolute", // default value to maintain compatibility
"@": [0, 0],
"#": [0, 64],
"a": [64, 0],
"!": [64, 64]
}
// ...
}
// OR
var displayOptions = {
tileMap: {
type: "grid",
"@": [0, 0],
"#": [0, 1],
"a": [1, 0],
"!": [1, 1]
}
// ...
}
// OR
var displayOptions = {
tileMap: {
type: "index",
"@": 0,
"#": 1,
"a": 2,
"!": 3
}
// ...
}
This could also be done currently, with something akin to
var Game = {
display : null,
tileWidth : 16,
tileHeight : 24,
tileMap : {},
tiles : {
player : { symbol: '@', sprite: [0, 0] },
enemy : { symbol: 'S', sprite: [0, 1] }
},
init: function()
{
Object.keys(this.tiles).map( function( tile, index )
{
var x = Game.tiles[tile].sprite[0] * this.tileWidth;
var y = Game.tiles[tile].sprite[1] * this.tileHeight;
this.tileMap[Game.tiles[tile].symbol] = [x, y];
});
this.display = new ROT.Display(
{
tileWidth: this.tileWidth,
tileHeight: this.tileHeight,
tileMap: this.tileMap,
// ...
});
// ...
},
// ...
}
Where we declare our grid offset in Game.tiles and iterate through that object to create what ROT.js expects in tileMap.
Instead of:
I was thinking something:
What do you think?