Archived

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

Rendering Player behind objects efficiently?

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

Hi, I am working on a diamond iso game and have everything working except i am just rendering the player last (which obviously makes him appear on top of everything), I was just wondering what is the best way to render the player/enemies/npc''s so that they are rendered at the correct moment, yet don''t take up so many clock cycles checking every position. I just checked the forum''s but maybe i''m using the wrong search terms. - Free Your Mind -

Share this post


Link to post
Share on other sites
EDIT:
OK, I just figured something out from your original post: you want to improve the speed at which the sprites are sorted? If so, use a pointer and possibly a linked list per map tile that points to (all) the sprite(s) currently on that tile. Then loop through all tiles from back to front and draw everything for each tile.

ORIGINAL POST, POSSIBLY ALSO INTERESTING:
Basically, you're doing the right thing, blitting from back to front. You could, in theory, however introduce some kind of system for checking if a tile is occluded so you don't have to draw it in the first place. Say you have a tileheight member of your sprite/character/whatever class or struct that specifies the number of tiles that it entirely covers. You then can calculate which tiles to draw, and which ones to skip, and if you enforce the system well, you should get a performance boost. I'm not sure how well this would apply to your engine. It might not work at all, but I hope I gave you a nudge in the right direction.

The ultimate solution (if you have lots of overdraw) would be to write your own blitting routines in assembly and creating your own equivalent to a simple Z-buffer, but I don't know if you really want to do that... You could write it in C/C++ too, but you'd probably spend some time optimizing it.

So:
If all of this sounds too complicated, just draw back-to-front and don't worry. If you want to get rid of overdraw you will have to use some sort of Z buffering system, either pixel-wise or on a larger scale, like tile-wise. You may also want to enforce it only on a limited scale, like only for static objects, and draw the rest back-to-front. It depends mainly on: (1) your skill, (2) the current performance and (3) the performance gain, i.e. how much overdraw you have as is.

- JQ
Full Speed Games. Period.

[edited by - JonnyQuest on July 26, 2002 12:46:07 PM]

Share this post


Link to post
Share on other sites
The way I see it would be to render a row of tiles, then render everything that stands on those tiles (players, enemies, objects), and then progress down to the next row which can potentially obscure the things on the row behind it.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]

Share this post


Link to post
Share on other sites
yes kylotan, but i''m curious about how the player/enemies fit into this because they maybe on more than one square at once, and this is my ''real'' question. Thanks


- Free Your Mind -

Share this post


Link to post
Share on other sites
You never mentioned that they might be on more than one tile at once.

Just draw them immediately after you draw the lowest row that they are currently occupying.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]

Share this post


Link to post
Share on other sites