-1
I am developing a TOP-DOWN game with several enemies, however, due to the order in which they are plotted on the screen, no matter if one is behind the other, always the one that was plotted last will have their Sprite drawn over the others.
I’d like to know if there’s a kind of third axis beyond the X and Y, so I can adjust in case the further south the enemy is, means the closer he is, and therefore the Prits should be above the others, as well as the further north, farther away you will be and your Sprite should be below the others.
It follows an excerpt in which through a loop I create 20 instances of the Enemies class.
i = 0
waves = 0
enemies = []
for x in range(20):
inimigo = "e"+str(i)
inimigo = Inimigo(player)
enemies.append(inimigo)
i += 1
And below follows excerpt I use inside the game’s "While True":
for e in enemies:
e.draw()
I think because of the above, enemies are plotted completely independently of each other. So they have no "consciousness" of each other, and end up having the superscripted sprites by the ones that were drawn last.
What I need is for there to be a way to control the depth of the screen, so that regardless of the order in which they were drawn, the one further south is ahead.
I hope I explained it well.
The execution of the game can be seen in https://www.instagram.com/p/B7j37-Bh_Jn/ and the complete code is in https://github.com/Nathanbahia/Exemplo-Pygame
One of the espcialized classes of Pygame Group allows a control like this - but without you putting a minimal example and working of how your code is, no one will answer - since you would have to write a whole program from scratch just to demonstrate this.
– jsbueno
In other words: please edit the question and include a minimum and complete (working alone) example of how it is, or the question will be closed.
– jsbueno