My unsolvable problem

Started by
45 comments, last by EDI 20 years, 1 month ago
Greetings all, I have been working on a 2D Isometric game engine for quite some time now *2 years I guess* and I have been able to overcome every problem it''s development has thrown at me, except this one. I''ve looked in the history of this forum to find an answer to my problem but all the methods I saw didint seem to work for me. The problem is Large Sprites, a sprite that takes up 2x4 tiles or perhaps 5x3 tiles something large. when I place this sprite *i call it a structure* I must place it on a single tile, this is it''s anchor tile, and it''s the tile that draws the sprite, now i can set an anchor on the sprite itself to that it''s offset from this anchor tile any way i want, but i discoverd that no matter where i set this anchor to it always caused me overdraw issues, i though about this for a while and found this is due to the fact that only a single tile is drawing this large multi-tile sprite. i''m sure most of you know what im talking about, so here are a few solutions i found but didint work for me. Split the object into multiple structures: this didnt work since it would add alot of overhead to designing and making graphics for the game, plus it would mean for an interactive sprite (clickable) i would need multiple objects that all are technicly the same sprite, it would require a sizable re-work of my engine to make it work, this method is just too complex and thus i cant use it. Sort the objects so that they draw back to front: I tried this, i sorted them by Y then by X and it still didint work, it would work of the sprites occupied a square region of tiles, but not certain rectangles. so, ive been racking my brain for a while now and i cant come up with a solution, im about at the point to just leave the 2D engine as is and start a 3D one, but this would mean 50% of my work was a waste and the game ive been working to create will be delayed and the work ive done on it was a waste too. so please if anyone can help me i would be extreamly greatful, if there is anything you need me to provide you with just let me know. thank you all in advance Raymond Jacobs, www.EDIGames.com www.EtherealDarkness.com

Raymond Jacobs, Owner - Ethereal Darkness Interactive
www.EDIGames.com - EDIGamesCompany - @EDIGames

Advertisement
If it is a large "structure" and not an item,npc,pc etc, when you sort by the y value, couldn''t you just place "structures" at the end of the y sort?
like A,B,C,D,E and F all have the same y value, but C is a "structure", so sort it ABDEFC. Is that possible with your current setup?


Evillive2
E-Mail
Evillive2
um, i dont think i understand what you mean.

this is an example of where sorting by Y fails





the grey area is the ''foot print'' of a structure

and the red dot within it marks it''s anchor tile

the yellow area is a sprite and the red dot is it''s anchor tile

if it is sorted by Y the sprite is drawn first then the structure is drawn over the sprite later =/

Raymond Jacobs,

www.EDIGames.com

www.EtherealDarkness.com

Raymond Jacobs, Owner - Ethereal Darkness Interactive
www.EDIGames.com - EDIGamesCompany - @EDIGames

This is one of those issues that i believe will unfortunately never be solved for solutions that use 2D APIs to render. In a solution that renders with a 3D API, this issue disappears, as the structure would be represented with a 3D model.

Get off my lawn!

Wouldn''t this work better if you used the point in the structure thats is the farthest back as the point that your drawing it from? ie. the highest point on the grey rect in your diagram, that would put it behind the sprite and anything else that is in front of it.. but I haven''t done this before so I''m probably missing something

Please visit Turt99 Productions
FOLLOW ME ON TWITTER OR MY BLOG
Turt99:

thank you for your reply,
while in the above example that might fix things it''s not a flexable solution, since:





still wouldnt work =/


TANSTAAFL:

thanks for your reply,
yes that is what i feared, i guess i had better start learning to make 3DGames then eh?

it seems like this would be more common of a problem though, i wonder what other people do to get around this *other than what i have mentioned, since they dont sound like ''good'' solutions*



Raymond Jacobs,

www.EDIGames.com

www.EtherealDarkness.com

Raymond Jacobs, Owner - Ethereal Darkness Interactive
www.EDIGames.com - EDIGamesCompany - @EDIGames

quote:
This is one of those issues that i believe will unfortunately never be solved for solutions that use 2D APIs to render.


Unless the objects actually intersect, there is nothing to stop you from rendering them in the correct order.
The only restriction is that the objects must be convex, or at least "close to" convex... (if they are not, split them into parts that are)

The problem cannot be solved by sorting along any axis, instead you must compare each axis separately.

the rules are quite simple to figure out if you think about bounding boxes (pen and paper are your friends).

The exact rules depend on what your coordinate system looks like.
thanks AP,

but as i mentioned splitting up the object is not an option,
it would require a very sizable rework of my engine and for a 2D game engine i cant see investing that much more time into it.

Raymond Jacobs,

www.EDIGames.com

www.EtherealDarkness.com

Raymond Jacobs, Owner - Ethereal Darkness Interactive
www.EDIGames.com - EDIGamesCompany - @EDIGames

Ah, dont switch to 3d because you cant solve a 2d layering problem without lots of work. Bah.

Now, I am not sure if I understand the problem correctly, but if I do:

This is a bit of a tricky problem you have on your hands though. I can think of a few more elegant solutions, but all of them would really cause a performance hit, and your drawing code for a 2d game like this is probobly already a bottleneck.

One possible solution might be to 'mark' all the tiles which a large multi-tile structure obscures. (using something like a linked list on every tile, the list would consist of links to structures that are obscuring that tile)

Then, you could go through and treat large multi-tile structures in a more sane way, and handle all the odd layering cases.
(as it would be possible to tell at a glance, what structures are drawn at any given tile)

Hope that helps somewhat.

[EDIT]
Note: I don't quite understand whats wrong with Turt99's solution. Your diagram doesnt seem to explain.

If the anchor is well choosen (as in your illustration), and structures stay fairly small (as in not dozens of tiles) then there should be no reason that what he is suggesting wouldnt work in all reasonable cases.
Maby i'm missing something?
[/EDIT]
- Jacob

[edited by - Kevlar-X on October 10, 2003 5:52:06 PM]
"1 is equal to 2 for significantly large quantities of 1" - Anonymous
thanks AP,

but as i mentioned splitting up the object is not an option,
it would require a very sizable rework of my engine and for a 2D game engine i cant see investing that much more time into it.

Raymond Jacobs,

www.EDIGames.com

www.EtherealDarkness.com

Raymond Jacobs, Owner - Ethereal Darkness Interactive
www.EDIGames.com - EDIGamesCompany - @EDIGames

This topic is closed to new replies.

Advertisement