I'm building a simple Mahjong based game in Lua. I'm adding a simple perspective to my tiles on the bottom-left edges. I can successfully generate the level in proper tile order if tiles don't touch half-way using the following code:
table.sort(self.tiles, function(tile1, tile2) if tile1.level_layer == tile2.level_layer then if tile1.level_y == tile2.level_y then return (tile1.level_x - tile2.level_x) > 0 else return (tile1.level_y - tile2.level_y) < 0 end else return (tile1.level_layer - tile2.level_layer) < 0 end end )
It works like a charm. However when I start implementing the half-way touching, everything fails. For example I cannot implement a solution for the following problem:
In example 1 is the way it should be rendered, but it gets rendered as example 2. Is there an easy way to implement such perspective?