Jump to content

  • Log In with Google      Sign In   
  • Create Account

btatarov

Member Since 15 Mar 2013
Offline Last Active Apr 04 2013 12:14 PM

Topics I've Started

Mahjong based tile perspective

30 March 2013 - 07:47 AM


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:

 

examplewy.png

 

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?


PARTNERS