Isometric Tile Map in T2D
by Storm Kiernan · in Torque Game Builder · 03/30/2011 (10:33 am) · 12 replies
a) is this possible?
b) how would I go about doing this?
c) what are the known drawbacks to doing this in T2D?
b) how would I go about doing this?
c) what are the known drawbacks to doing this in T2D?
#2
And to accomplish this, you will use sort points + layer editing. This is how the TGB Adventure Kit works.
03/30/2011 (11:07 am)
Quote:EDIT: Calculating who is in front of another is (probably) just figuring out which sprites bottom is furthest down and making that sprite the one on the closer layer.
And to accomplish this, you will use sort points + layer editing. This is how the TGB Adventure Kit works.
#3
I retract my entire first post.... In regards to your 3 questions my answer is: Buy the TGB Adventure Kit.
03/30/2011 (11:17 am)
Does the adventure kit do Isometric? It must...I retract my entire first post.... In regards to your 3 questions my answer is: Buy the TGB Adventure Kit.
#4
03/30/2011 (11:24 am)
I will definitely be buying the TGB Adventure Kit, but I was not sure if it actually did Isometric. If it does, all is well and good. If not, sticking to a grid is the bare minimum requirement of the project and will work.
#5
Make your grid like this (layer numbers)
I realize I missed a whole bunch of layers but it shows what I mean.
I used code tags to try and get it to format the white space as I wrote it.... 32 wont go where I want it but you get the idea.
03/30/2011 (11:27 am)
If you can do a grid that is the easiest wayMake your grid like this (layer numbers)
32 31 31 30 30 30 29 29 28
I realize I missed a whole bunch of layers but it shows what I mean.
I used code tags to try and get it to format the white space as I wrote it.... 32 wont go where I want it but you get the idea.
#6
03/30/2011 (12:33 pm)
I am honestly not tracking with you on this one. I am imagining that this would limit my amount of tiles to 32 down...but I could be seeing this wrong.
#7
As Mich pointed out you can sort inside the layer, though I have no idea how to do this. You could use the TGB adventure kit code as a reference.
03/30/2011 (12:39 pm)
The engine limits you to 32 numbered layers.As Mich pointed out you can sort inside the layer, though I have no idea how to do this. You could use the TGB adventure kit code as a reference.
#8
03/30/2011 (7:14 pm)
The TGB Adventure Kit does not do anything that the stock engine can't. It's all script code, editor work and well set up art. It's a great starting off point, but keep in mind it was written for a previous version of the engine that does not use behaviors. It's all custom script code and functions.
#9
03/30/2011 (8:37 pm)
It appears that there is no non-hacky way of doing this without editing the C++ source code. TGB Adventure kit is not isometric, and I can't imagine that its as simple as just rotating the map object 45 degrees; since even that isn't isometric...
#10
and if you don't have more than 32 objects in your scene then you can do it easily with a few script functions.... and I'm sure you can extend the number of layers to 128 or 256 easily with source code... There may even be a resource on how to do it.
This isn't hacky, it's game programming.... I realize they are close to the same thing. But there IS a difference, I think.
If you have a budget for your game I could extend the number of layers and write an image sorting function for you that will reassign layer numbers given a list of objects.
03/31/2011 (5:49 am)
I literally just told you how to do this... It's just layer reordering.and if you don't have more than 32 objects in your scene then you can do it easily with a few script functions.... and I'm sure you can extend the number of layers to 128 or 256 easily with source code... There may even be a resource on how to do it.
This isn't hacky, it's game programming.... I realize they are close to the same thing. But there IS a difference, I think.
If you have a budget for your game I could extend the number of layers and write an image sorting function for you that will reassign layer numbers given a list of objects.
#11
[][][][][][][] : 0
[][][][][][][] : 1
[][][][][][][] : 2
[][][][][][][] : 3
[][][][][][][] : 4
Row 0: Layer 31 (in the tile map? or in the engine? this is where I am confused)
Row 1: Layer 30
Row 2: Layer 29
Row 3: Layer 28
Row 4: Layer 27
I would assume that this might not be too hard...calculate which row the object is on and push it up or down to the appropriate layer. This would of course limit the number of tiles in the Z direction to be 32. (You said objects..can you tell me why it would limit the objects?)
Am I correct so far?
I also want to be able to stack objects on top of each other. This would of course mean that they are on the same tile (x,z) location. However I would have to offset it by a certain amount (faking the Y). Does this sound right?
I apologize for not catching on as quickly as might be expected, but I am totally new to Torque.
edit: Also to make this work most efficiently, I am wanting to put the sorting code in one call that executes just before drawing. Is this possible?
03/31/2011 (9:32 am)
OK, let's back up and assume we aren't even talking about Isometric (just to make the drawing easier)[][][][][][][] : 0
[][][][][][][] : 1
[][][][][][][] : 2
[][][][][][][] : 3
[][][][][][][] : 4
Row 0: Layer 31 (in the tile map? or in the engine? this is where I am confused)
Row 1: Layer 30
Row 2: Layer 29
Row 3: Layer 28
Row 4: Layer 27
I would assume that this might not be too hard...calculate which row the object is on and push it up or down to the appropriate layer. This would of course limit the number of tiles in the Z direction to be 32. (You said objects..can you tell me why it would limit the objects?)
Am I correct so far?
I also want to be able to stack objects on top of each other. This would of course mean that they are on the same tile (x,z) location. However I would have to offset it by a certain amount (faking the Y). Does this sound right?
I apologize for not catching on as quickly as might be expected, but I am totally new to Torque.
edit: Also to make this work most efficiently, I am wanting to put the sorting code in one call that executes just before drawing. Is this possible?
#12
When I say object I mean t2dStaticSprites, t2dAniamtedSprites, etc etc.
When you create it you specify a layer. or you can use %obj.setLayer(%num);
If I create multiple objects in 1 layer, the most recently created one will show up on top.
Your layer diagram is correct. and you would have 32 rows of tiles, basically.
if you wanted to sort the objects in a single layer you would have to do the sort point thing Mich described (I don't know how this works but it's probably dead simple)
What I meant by limiting objects was that if you only had 32 objects then every object could have it's own layer and you simply resort whenever anything moves. To have more you have to add more logic.
It would be more efficient to sort whenever you have a change as opposed to every render call. and it's easier.
If you want arbitrary movement with proper sorting then you are going to have to do something like this:
loop through all your objects (keep them in an array) and sort them by which has the lowest bottom point
aka. position + (ysize / 2) // top left is 0,0
then do the layer reordering Mich described, or place them in different layers from 31 - 0.
03/31/2011 (9:49 am)
The engine limits your visual layers to 32. Layer 31 is the furthest away. Layer 0 is closest.When I say object I mean t2dStaticSprites, t2dAniamtedSprites, etc etc.
When you create it you specify a layer. or you can use %obj.setLayer(%num);
If I create multiple objects in 1 layer, the most recently created one will show up on top.
Your layer diagram is correct. and you would have 32 rows of tiles, basically.
if you wanted to sort the objects in a single layer you would have to do the sort point thing Mich described (I don't know how this works but it's probably dead simple)
What I meant by limiting objects was that if you only had 32 objects then every object could have it's own layer and you simply resort whenever anything moves. To have more you have to add more logic.
It would be more efficient to sort whenever you have a change as opposed to every render call. and it's easier.
If you want arbitrary movement with proper sorting then you are going to have to do something like this:
loop through all your objects (keep them in an array) and sort them by which has the lowest bottom point
aka. position + (ysize / 2) // top left is 0,0
then do the layer reordering Mich described, or place them in different layers from 31 - 0.
Torque Owner Chris Labombard
Premium Preferred
Make your images and calculate what layer they are on and what position they should be in.
Isometric simulates a 3D environment so you will have to do some collision trickery to make it appear as if one obejct is standing behind another despite the fact that they are layered and the images are technically touching.
Or you could make everything conform to a grid. but that's lame.
I would suggest your collision objects for your "models" (aka static sprites) are wrapped around the feet of hte sprite so that a different sprite can walk "behind" another.
The difficult part is calculating and applying layers (You only have 32 layers) to make things look right.
I didn't organize this post in any way so hopefully it is useful despite being a mind dump.
EDIT: Calculating who is in front of another is (probably) just figuring out which sprites bottom is furthest down and making that sprite the one on the closer layer.