We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c081876 commit 06151fdCopy full SHA for 06151fd
main.cpp
@@ -286,6 +286,11 @@ int main()
286
//---- Draw items ----
287
// Draw tilemap with walls and healthPickups
288
renderer.draw(window, map);
289
+ // Sort by Y position before drawing, so that the highest objects are drawn first
290
+ std::sort(entities.begin(), entities.end(),
291
+ [](const std::shared_ptr<Entity>& a, const std::shared_ptr<Entity>& b) {
292
+ return a->getPosition().y < b->getPosition().y;
293
+ });
294
// Draw all shadows for entities (enemies and player)
295
for (auto& e : entities) { e->drawShadow(window); }
296
// Draw and update all entity sprites
main.exe
3.5 KB
main.obj
12.9 KB
0 commit comments