Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

EDI

My unsolvable problem

This topic is 5251 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!