Jump to content
  • Advertisement

Archived

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

Drawing order?

This topic is 6610 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

I am making a real time strategy game, and i have a problem... You see, I have some units that have a different sized footprint than picture (like large buildings). This results in bad stuff when I draw them all out of order with farther away sprites ending up on top. Is there a way in DDraw to set a priority for a whole load of blits and then execute them all at once? Or am I missing the obvious solution? ~BenDilts( void );

Share this post


Link to post
Share on other sites
Advertisement
Well actually, DirectDraw does not blit all your pics at the same time. It will draw one at a time, but so fast it seems like all at once (hopefully at least 30 times per second). Anyways, you probably have some kind of loop to draw each map tile right? Just have your program draw the map tiles starting from the back (probably the top of the screen) and finishing in the front (probably the bottom). That way, the buildings and units and whatnot are drawn after, and thus on top of the previous structures which are in the background. You will probably want to start blitting at the upper left of the screen, drawing each horizontal row of tiles in a downward succession. Hopefully that will work fine.

Share this post


Link to post
Share on other sites
Yes units are not part of the map, but they should be drawn at the same time. If you draw your map with tall structures first and then all the units, what happens with the units that are "behind" the tall structure?
Just an idea - maybe you should draw the actual terrain first (grass, hills, trees, etc.), then the units (tanks and infantry or whatever), and then lastly the structures and buildings. That way the units are always on top of the terrain but could be drawn behind a tall building

Share this post


Link to post
Share on other sites
I think you shoul use layers. For example the ground tile would have layer 1, the buildings and units layer 2. When you draw you ad another loop for the layer that goes from the firs layer to the last. Then when you draw something you see if it''s layer is equal with the curent layer. If it is you raw it, otherwise you don''t. Also you''ll have to draw from back to front like CoolMike said.

Octavian
e-mail: octavsoft@octavsoft.freeservers.com
webpag: octavsoft.freeservers.com

Share this post


Link to post
Share on other sites
I FIXED IT!

Just in case you were wondering, I stored in each map square not only if there was a unit there, but which one it was. Then I went from the top to bottom of the map drawing the units using that index. Works great. Thanks for the input tho.

~BenDilts( void );

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!