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\$
  • 2
    \$\begingroup\$ You should add an image showing the end result that you're expecting. \$\endgroup\$ – Vaillancourt Apr 14 '17 at 19:59
  • \$\begingroup\$ Or at least an image of what you have now and a description of what's undesirable about it. \$\endgroup\$ – Draco18s Apr 14 '17 at 20:26
  • \$\begingroup\$ @AlexandreVaillancourt my question is : 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\$ – Reign Ravel Apr 15 '17 at 6:45
  • \$\begingroup\$ @Draco18s I added a comment above \$\endgroup\$ – Reign Ravel Apr 15 '17 at 6:46
  • \$\begingroup\$ Give this a read: gamedevelopment.tutsplus.com/tutorials/… \$\endgroup\$ – Draco18s Apr 15 '17 at 13:56
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\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.