![]() ![]() The bigger the rectangle, the more imprecise the calculation. Problem with this is approach is one of problems of Painter's Algorithm: the distance to camera is calculated from position of center point of the rectangle. Than calculated average 3D position of every entity and it's distance to camera. Sorting Characters and Bridges using "Painter's Algorithm" (average distance to camera of 3D rectangle vertices)Įven though the graphic engine is 2D, I defined every Character and Bridge as 3D positioned rectangle, and defined virtual camera (view point) with 3D position. When two Characters are close enough together on Y axis to overlap, and each one is on a different Floor, this happens: Problem with this is approach, that Floor has to have a hard edge.Įach Character is at one point on one and only one Floor. Sorting Characters into lists by Character current Floor, than sort each list by Character current Y ![]() ![]() Obviously doesn't work because it can't solve verticality (Floors). Visuals (tiles) that make rest of the game level, are rendered first (under everything else) in one pass, and don't need any kind of sorting. Characters and Objects can be positioned / move both on and under a Bridge.Įntities that need their sprites sorted are Characters, Objects, Bridges.Characters can be positioned / move behind other Characters and pass through each other.Characters and Objects cannot be positioned / move "behind" back-facing walls and behind Objects.Staircase can connect 2 Floors that can be any number of Floors apart. Staircase is a "ramp" connecting 2 Floors. Objects (crates etc.) can be positioned on any Floor. ![]() Characters (Player characters, enemies, NPCs) can be positioned and move around any Floor and move between Floors.I am having trouble figuring out a working system for sprite drawing-order sorting for this specific game. I am working on custom 2D engine for a game. ![]()
0 Comments
Leave a Reply. |