I have a data structure I created myself, it's called characters.
This data structure has the following method
addCharacters(self, Character, number)
This allows the user to add as many characters to the screen. In this method, an array initialized in the __init__ constructor is appended to add the Character object.
I have a class screen, in this class I have the following method
addCharacter(self, Character, x, y)
this draws the character on the screen like so:
self.screen.blit(character.image,(x,y)
I call these methods in the main class where the code is run. a while loop to represent the game running is created. in this while loop the objects must be drawn, so screen.blit must happen in the while loop.
Here is the problem: when I call the method myarray.addCharacter(character,4) outside the while loop, and
for characters in charactersList:
screen.addCharacter(character, random.randrange(0, screen.width), random.randrange(0, world.screen))
The image erratically blits on the screen at different locations. I understand this is because of the for loop inside the while loop. I can't add the character outside the while loop as it won't draw to the screen.
Is there a way I can set the location of each object in this data structure all at a different position without constant blitting?
Thanks in advance!