Depth sorting - almost solved

For questions about using Classic.

Post » Thu Jan 14, 2010 4:28 am

Hey as a lot of you know I've been stuck on depth sorting for ages.
I've come up with some sorting events, that in my mind, make complete sense and SHOULD work.
However they don't seem to be working as planned. Here it is:



Does anyone have any idea why this wouldn't work properly?
I ran a small test that, instead of using a for loop, I used a user controlled variable that was increased and decreased by pressing the up and down arrows and it worked perfectly. But when I'm using the loop it doesn't work :(
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Thu Jan 14, 2010 5:21 am

what is it that you're trying to accomplish?
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Thu Jan 14, 2010 5:23 am

Isometric/orthographic sorting with Z Height.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Jan 14, 2010 5:36 am

The loop 'scans' from the ground up and if the 'height' of the loop (the loop index) is between any objects that need to be sorted's height variables (lower edge and upper edge) it sorts any of the picked objects in ascending order of where their Y value (regardless of 'height') and brings them to the front in that order.
Now for debugging purposes I made it so it didn't use a loop but used a user control variable that i could raise or lower, just so i could monitor what's going on wherever the 'scanline' is at. I made the picked objects change tint to see what I was working with. When using this method, it actually sorted everything fine, but the loop method does not work so well.

p.s. this sorting method does however require that tall objects be split up but meh
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Thu Jan 14, 2010 6:04 am

Ah dam I think I realised why this doesn't work now. As soon as two overlapping objects of the same size are at different heights, the one who has the highest top edge variable will be put in front, even if it's Y co-ordinate is behind it due to the way I'm scanning it :(
False alarm by the looks of it... as these things usually are.
But I think I'm still pretty close and I'm going to explore some options once i figure them out ;)
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Thu Jan 14, 2010 8:43 am

Hint: Try out the "For each object (ordered)" under system conditions.

For example, me & Zotged used this in our isometric game:

For each Blue ordered by Blue.Y -> Blue: Send to front

Should make things quite a bit simpler for you :)
B
16
S
8
G
4
Posts: 136
Reputation: 3,144

Post » Thu Jan 14, 2010 9:20 am

Heheh I -am- using that :wink:
That works great if you don't use height, but I'm putting jumping and stuff in, and the sorting becomes a NIGHTMARE.
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Thu Jan 14, 2010 9:26 am

Imagine a 2D grid, slanted so it looks like a table. Top rows are behind, bottom rows forward. When you add objects, you can influence their Z-ordering by the position on this grid. You can change their elevation all you want, however their position on the grid remains the same. It should always be drawn in front of objects with higher grid position etc.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Thu Jan 14, 2010 10:15 am

Let me just put it out there that i'm not making a 'strictly' isometric game, I'm going more for a pixel by pixel treatment rather than a tile by tile, it doesn't stick to the old diagonal layout that most of them have as I'm going for a more natural look. But really, the theory should be basically the same.

@Mipey - can you go into further detail as to how you would go about such a thing? I do know how it -should- be drawn, i just can't for the life of me figure out -how- I will be able to do it
B
3
S
2
G
5
Posts: 351
Reputation: 2,377

Post » Thu Jan 14, 2010 12:07 pm

Oh, just use invisible sprites that you do actual movement and stuff with, then add 'visible' sprites to them and sort them based on the 'base' sprite's Y position. So when you change the height, you actually don't move the 'base' sprite, you move the 'visible' one up by height.

That should be the simplest way to go, I think.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests