Hello. The situation needs help.
I (for the game) need the characters to be drawn gradually (as if the game understands which character is closer to the camera and which is not).
And at the same time, that there were rendering layers.
While there were few objects, I managed the usual double for () in height (from top to bottom I checked each object to see if it matches the desired height, if so, I drew).
for(int i=int(-h/10); i<int(h+h/10); i+=h100){
//hero
if(int(posHero.y)>=i&&int(posHero.y)<i+h100){drawHero();}
//enemy
for(int ii=0; ii<100; ii++){
if(typeEnemy[ii]!=0){
if(int(posEnemy[ii].y)>=i&&int(posEnemy[ii].y)<i+h100){drawEnemy(ii);}//if enemy pos y == i
}//if need draw enemy
}//for draw enemy
}//for
What happened - added a picture.
But there are more objects, I need a new code.
I know that sounds silly and hard to understand.
But try, please.