Most efficient way to save tile data of an isometric game
Andrei BotalovHarmen提出了一个问题：Most efficient way to save tile data of an isometric game，或许与您遇到的问题类似。
If you are trying to do something like the picture you don’t need to store which corners are up/down as it can be deduced from the surrounding tiles.
For example if the current tile is height
n and the height of the tile one up from the current tile is height
n+1 then the current tile must have “top corner up”
Great! Thank you! I’ll try to implement this. One more thought to complete your answer: is it possible to store height and tile ID as an integer?
Yes. You will need to use Bitwise Operations.
If you divided the integer equally between height and id using the first 16 bits for height and the rest of id
var id = tile & 0x0000FFFF; //mask the first 16 bits var height = tile >>> 16; //shift the first 16 bits to the right
Setting can be done in a similar mannar
tile &= 0xFFFF0000; //remove id bits tile |= id; //set new id tile &= 0x0000FFFF; //remove height bits tile |= (height << 16);