Skip to main content
GameDev.net gamedev.net
🔒 Locked

An isometrical problem....

Started by zhak Sep 19, 2005 at 3:11 PM 5 replies 3.3k views
Original Post
zhak
zhak
Ok people... I am currently developing a isometrical 2d engine, but I'm stuck with 1 major problem, and getting an headake because i don't find out the right solution. Ok so I am trying to draw a portal, or a door, and make the engine "understand" when the sprite that pass trought must be over or under the portal... i know there is a solution, but i can t figure it out look at this screenshot that i make from haboohotel, there is on the left side of it a portal, and it work fine... do you know a tutorial or some resources that give some advice to implement it ? i found lots of tutorial about isometrical, but never about protal or doors ... thanks a lot cheers. Laurent
EDI
EDI
slice the door in two pieces, and have them draw indipendantly.

asuming that you have things sorting then this should work fine.



there is a more complex way of doing this which does not require slicing the art, but it is tricky.

also, a LOT depends on the art, there are certain art combiations that will simply not work, even with the slicing. (if the character is near the same size as the door.)
H_o_p_s
H_o_p_s
Oh! I like that! And here all this time I have been trying to do them on seperate layers.... thanks for that tip EDI!
BRING BACK THE BLACK (or at least something darker)
zhak
zhak
Thanks you edi I'll try your method..
I have also another problem, perhaps you could also give me an hand.

I have my engine working fine for quite a lot of thing I want it to do, but I'm faced with the problem of the order of drawing item (thing that take more than one cell, like portal for example, or lot of other things).
I'm drawing item like that :

X ->
| +-+-+-+-+-+
v | | | | | |
+-+-+-+-+-+
| | | | | |
+-+-+-+-+-+
| | | | | |
+-+-+-+-+-+

So from the top cell, then i draw all item from the left to the right,
then I pass to the next row, etc...

In this case it is a protal, so your method could work here I think, but imagine another object..
For instance:

(row:col)
Top cell is 0:0
Bottom cell : 5:5

If I have an object at 3:3
And another one at 4:2

In a normal system, the object at 3:3 must hide a part of the object at 4:2
But here it is drawn first, then the one at 4:2 is drawn, so it hide the first one, and it is not ok.. look at the screenshot i made and you will see what i mean..each portal is drawn from its more bottom cell.


I dont know, perhaps my engine work fine and this is a too particular case, but
i think this could also be handle...




Thanks you

Cheers.
Laurent

Luckless
Luckless
Zhak, I'm looking at this, and I think you have a sorting problem. The one in behind where your arrow is pointing seems to be drawn AFTER the one in front. Stuff that starts closer to the top of the screen needs to be drawn FIRST.

You might want to consider drawing things only in single tile columns, so an arch isn't connect to its pillar, this means you can also adjust heights of things nicely by adding more pillar componets to a stack, and then adding on the arch.
Old Username: Talroth
If your signature on a web forum takes up more space than your average post, then you are doing things wrong.
streamer
streamer
again use Edi's method. separate larger objects in smaler pieces that occupie just one tile...
EDI
EDI
As was mentioned, splitting things into column-sized chunks works great.

However it is a bit of a pain to do that, so there IS another solution.

First and Foremost it requires knowledge of a structures displacement, in x and y tiles

the structure you showed in the last screen shot is a 1x5 displacement (1x 5y)

this data will need to be availible to the rendering method.

This rendering method we call LORM (Large Object Rendering Method), the basic idea, is that when you see that you are about to rendering a structure with more than a 1x1 displacement, you must first render things that it would cover.

here is a diagram of the rendering proccess:



The numbers signify the order in which the tiles are rendered.

Blue = Walls 1x1 displacement
White = No Structure
Red = Structure Displacement
Yellow = 'anchor' tiles, the tile were the large structure 'exists'
Green = other structuers 1x1 displacement

On this diagram we observe two large structures:

A 4x3 structure and a 3x1 structure

Lets go over the rendering process:

Rendering goes from 1 to 11 simply, from top to bottom left to right.

When it comes upon the Anchor Tile of the large structure, it notices that the structure is not 1x1.

Instead of rendering the structure, it renders all of the tiles above it, which is a 4x3 section in this case, these are renderd in the same order top to bottom left to right.


During this sub-rendering operation, it encounters ANOTHER large structure, the method is done for this structure as well.

Once a large structure has it's sub-rendering done, it then draws itself.

Note, that the implementation of this function has the tendancy to re-draw things that have already been drawn, so to avoid this, you should have a column array of numbers

long lastRowRendered[nColumns];

before any rendering is done set it all to 0, then as you render a row in a given column, update the last row that was rendered in that column, and when drawing never draw a part of a column if it's row is less than the last row drawn.

It takes a lot of work to wrap your head around this method, but once you do and implement it, it seems to work in almost all cases.

Good Luck =)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.