summaryrefslogtreecommitdiff
path: root/src/render.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/render.cpp')
-rw-r--r--src/render.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/render.cpp b/src/render.cpp
index f56cb37..ce9b837 100644
--- a/src/render.cpp
+++ b/src/render.cpp
@@ -79,6 +79,7 @@ void state_t::render(game::state_t *game)
sf::Vector2u size = window->getSize();
sf::Vector2f A, B, C, D;
sf::Rect<float> bbox;
+ std::list<world::entity_t*> ents;
A = window->mapPixelToCoords(sf::Vector2i(0, 0));
B = window->mapPixelToCoords(sf::Vector2i(size.x, 0));
@@ -93,7 +94,15 @@ void state_t::render(game::state_t *game)
for (world::sector_t *sector : game->world.get_sectors(bbox))
draw_sector(window, sector);
- for (world::entity_t *ent : game->world.get_entities(bbox))
+ ents = game->world.get_entities(bbox);
+ ents.sort(
+ [](const world::entity_t *x, const world::entity_t *y) -> bool
+ {
+ return x->bounds.top + x->bounds.height
+ < y->bounds.top + y->bounds.height;
+ });
+
+ for (world::entity_t *ent : ents)
ent->render_to(this);
}