0
\$\begingroup\$

how is it possible to draw the player behind and in front of some building in an isometric map : should I slice them, replace the number in the map (one number for a tile usually) by an array of number (each being a piece of a bigger tile), and somehow add a Z-order related to each small number (the pieces of building), something like this?

//replace :
var map = [
    [1,0,1],
    [0,1,1],
    [0,0,1],
    [0,0,1]
];

//by :
var map = [
    [["2-zOrder/1","3-zOrder/1"],0,1],
    [1,1,1],
    [1,0,1],
    [0,0,1]
];

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ How would you write the code in order to make it easy to manage. Is there a common way to make the "top" of a building appear in another tile, with a different Z value than the other tiles already in there? -> The bottom of the tile, the green square, would be in a tile, but the top of the building should be in another tile, with a different Z order, so that the player is hidden when he walks through the village. Is there a better way than an "array of array of array" with "zOrder/1"? \$\endgroup\$ Commented Apr 15, 2017 at 6:45
  • \$\begingroup\$ Give this a read: gamedevelopment.tutsplus.com/tutorials/… \$\endgroup\$ Commented Apr 15, 2017 at 13:56
  • \$\begingroup\$ Using depth map. Just it. \$\endgroup\$
    – Haruko
    Commented May 21, 2017 at 17:35

1 Answer 1

1
\$\begingroup\$

I used a straight forward approach for this.

My map (not the end result!) is set up us horizontal lines, where i go from top to bottom, blitting everything from left to right. That way I automatically place everything in the correct order. My tiles (not walking sprites, they have their origin at (0,y) !) all have their origin in the left-middle, or (0,y/2) assuming (0,0) is in the top left.

If you struggle with height, then just blit the ground layers first, then add the top layers, also from top to bottom.

Did this make sense?

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .