I'm making a topdown 2d game, and I've made a decent entity system so far. But I want to do the following with it: I want to have drawing depth, so if, for instance, a tree is above another tree, then it should be drawn underneath the other tree. Here is basically a picture of what I mean.
This is what I'm trying to avoid:
[![This is what I have RN, but it's bad][1]][1]
Instead of that I want something like this:
[![This is what I'm trying to achieve automatically in rendering][2]][2]
If you have any idea how to do this, please tell me. If you need any code, here's basically what I do: In my main class I call a generate entities class. In that then I add Tree class-es to an arraylist through which it renders them. Thanks. [1]: https://i.sstatic.net/KpqpK.jpg [2]: https://i.sstatic.net/fjpDR.jpg