Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Depth sorting in isometric world?

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Jun 2013 15:54 Edited at: 25th Jun 2013 16:12
Trying to expand upon my prior isometric map loader by adding character placement. I set it up so that each tile(sprite) is set to a different depth.

This isn't my picture, just using it to demonstrate the order the tiles are number.


So tile 0,0 is given a depth of say 1000 and then the depth counts down for each tile after that. Since sprites of the same depth are drawn in the order created, additional layers use the same depth values.

I can't seem to get things sorted correctly, especially with the multiple layers. Anyone have insight on this?


Ok, I believe I've worked out the sorting. I think it was just the way the graphics were drawn were causing weird things to happen that was throwing me off.

haliop
User Banned
Posted: 25th Jun 2013 16:15
so have you fixed it?
can you explain how to fix it so we will know?
what i would do with isometric
is
all the tiles should be the same depth..
and chars / trees / additionals -1 or so ..

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 25th Jun 2013 16:17
I've worked on an iso map quite a while ago, and recently in fact, although I haven't got to adding objects in as yet. In my earlier demo (there is a video on my youtube channel), I simply used the y position of the sprites. So make sure your sprite offset is at the middle of the sprite (so the left and right corners of the iso tile align) and set your sprites depth according to the sprites height on screen. It's been awhile so I kind of fuzzy on the precise details, but that is basically the way to do it. I was thinking of doing a tutorial based on my code, but it's a little early yet to start. Pity my old demo got wiped in a hdd crash, as I could have pulled the code out for you.

My current iso engine runs nicely on both PC and my android (a steady 60fps). It allows for any size map you want (pretty much) and has basic (very) random ground generation.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Jun 2013 23:12 Edited at: 25th Jun 2013 23:29
Quote: "all the tiles should be the same depth..
and chars / trees / additionals -1 or so .."


It's not completely that simple. For a base layer, something like the ground or grass that the player can never be behind, then yes I can make all those the same depth. But once you start adding layers of other objects it gets more complicated.

Ok, say layer 1 is just dirt on the ground. All tiles are set to a depth of 10. Layer 2 contains trees, make their depth 9 so they're drawn on top. Layer 3 may contain other things. Now here's the problem. What happens when objects from layer 2 and 3 are close enough that both are within the space of the character? What if a layer 2 object is placed where it should be in front of something from layer 3? This is why each tile needs its depth sorted separately and why objects likes trees that are larger than a single tile need to be a single object. Trying to map a tree that's perhaps 2x6 tiles in size but broken up into individual tiles (like I was doing) didn't work. The player could be behind the stump of the tree but his head still appears in front of the upper branches because they lie in a row of tiles above the base, thus being drawn first.

It's easier to show than explain.

I'll try your suggestion dvader and see if that clears up any other issues.


haliop, here's a picture that might help show the problem with simply changing depth based on layer. Imagine the red block is on layer 2 and blue is on layer 3. Using your method, the red block is drawn first and thus will appear behind the blue one when it should not be.



Attachments

Login to view attachments
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 26th Jun 2013 20:06
For my RPG tests, i was using an home made technique using a sort of tile "bounding boxes" depending on floor height and width of each visible tiles to know if my tile was behind or front of my player :



It was working well for me without splitting any tile
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Jun 2013 20:09
Looks great Mike!

swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 27th Jun 2013 02:47
@Mike
There is a slight hiccup at 0:34 with the tree leaves (It waits a bit too long to swap the depth. If you pause at the right moment you can see your character standing on the leaves ) but otherwise that sure looked pretty solid

swis
Joined: Tue Dec 16th 2008
Interstellar
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 27th Jun 2013 02:51
yes i saw it but i have to check if i have fixed it (i think i did in an earlier version). This is an old video
swissolo
14
Years of Service
User Offline
Joined: 9th Jan 2010
Location:
Posted: 27th Jun 2013 03:32
Quote: "yes i saw it but i have to check if i have fixed it (i think i did in an earlier version). This is an old video "

Ah alright!

swis
Joined: Tue Dec 16th 2008
Interstellar
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 27th Jun 2013 11:33
I've done a quick video tutorial on how I achieved this in my old demo. It's currently being encoded, but will be up later today.

Login to post a reply

Server time is: 2024-11-24 15:52:59
Your offset time is: 2024-11-24 15:52:59