mage-city
mage-city copied to clipboard
Support Tiled tile flipping
From the docs:
When you use the tile flipping feature added in Tiled Qt 0.7, the highest two bits of the gid store the flipped state. Bit 32 is used for storing whether the tile is horizontally flipped and bit 31 is used for the vertically flipped tiles.
To enable variation while editing levels it would be useful to support at least horizontal and vertical tile flipping (we can add diagonal flip later). Flipping bits should be extracted by elmify
utility and possibly stored into the B channel of the LUT which is actually unused.
Then, shader would extract the bits and invert the final tile coordinated according to those values.
Note: I was assuming that WebGl 1.0 supports bitwise operations. It turns out this is not the case. However, since we need to test only two bits we can easily check against four hardcoded integer values (e.g. 0 = no flipping, 1 = flip h., 2 = flip v. and 3 = both h. & v. flip).