Hi,
I'm messing about with an isometric game. The logic is all 2D, and it is drawn as an isometric game.
The idea is to be able to draw a map something like the old xcom games:
To do this, depth sorting is needed. In order to have objects that are larger than a single tile, it's best to generate a directed acyclic graph of which objects are behind others, then topologically sort that (like shown here: https://shaunlebron.github.io/IsometricBlocks/).
The problem is this is O(N^3), so, not ideal if there's a lot of objects. Additionally, it's not clear how to achieve multi-level buildings and things in this setup - as the floor is 'flat' and should always be beneath everything.
It's necessary for the depth sorting to be able to determine if one object is in front of another, which requires them to have a 3D volumes and for them not to intersect. So, one option is that floor tiles can be considered objects and have a height of 1. Then, the second level of walls be at a z position of the wall height + 2, (Floor is wall height + 1, then +1 height). This is not ideal, as then when there are walls atop each other spanning multiple levels but without a floor in between, we have a gap. I suppose there could be 'different' walls for when there is and is not a floor, but that's getting excessively complicated. Also, each floor tile then needs to be depth-sorted. However, if you look at the green 'cursor' in the top image, it seems as if there is indeed a gap between levels in the original game. Another issue with this approach is that I'm having issues with cycles in the directed graph using this method (i.e, two objects say they're behind each other, so it'll loop indefinitely when trying to topologically sort). I believe this happens when objects are intersecting.
Another options to use layers. Layer 1 for the ground floor, layer 2 for all ground-level objects, layer 3 for second level floor, layer 4 for second level objects. This is nice as it handles a bit of the depth handling, and we don't need to do any depth sorting for the flat floors. Furthermore, depth sorting is done on a layer-by-layer basis. This has the downside that now objects must be axis-aligned in the z direction, and can't be taller than whatever we define as a level's height. So it has some upsides but is probably way too restrictive.
I'm struggling to come up with other ideas for how to achieve this, so any thoughts would be good.
I'm messing about with an isometric game. The logic is all 2D, and it is drawn as an isometric game.
The idea is to be able to draw a map something like the old xcom games:
To do this, depth sorting is needed. In order to have objects that are larger than a single tile, it's best to generate a directed acyclic graph of which objects are behind others, then topologically sort that (like shown here: https://shaunlebron.github.io/IsometricBlocks/).
The problem is this is O(N^3), so, not ideal if there's a lot of objects. Additionally, it's not clear how to achieve multi-level buildings and things in this setup - as the floor is 'flat' and should always be beneath everything.
It's necessary for the depth sorting to be able to determine if one object is in front of another, which requires them to have a 3D volumes and for them not to intersect. So, one option is that floor tiles can be considered objects and have a height of 1. Then, the second level of walls be at a z position of the wall height + 2, (Floor is wall height + 1, then +1 height). This is not ideal, as then when there are walls atop each other spanning multiple levels but without a floor in between, we have a gap. I suppose there could be 'different' walls for when there is and is not a floor, but that's getting excessively complicated. Also, each floor tile then needs to be depth-sorted. However, if you look at the green 'cursor' in the top image, it seems as if there is indeed a gap between levels in the original game. Another issue with this approach is that I'm having issues with cycles in the directed graph using this method (i.e, two objects say they're behind each other, so it'll loop indefinitely when trying to topologically sort). I believe this happens when objects are intersecting.
Another options to use layers. Layer 1 for the ground floor, layer 2 for all ground-level objects, layer 3 for second level floor, layer 4 for second level objects. This is nice as it handles a bit of the depth handling, and we don't need to do any depth sorting for the flat floors. Furthermore, depth sorting is done on a layer-by-layer basis. This has the downside that now objects must be axis-aligned in the z direction, and can't be taller than whatever we define as a level's height. So it has some upsides but is probably way too restrictive.
I'm struggling to come up with other ideas for how to achieve this, so any thoughts would be good.