I have a for loop that takes values from a text file, and then creates and adds a bunch of sprites to a group platformlist_list. The for loop will continue until every line of the text file is read.
self.object = Wall(firstarray , int(firstarray), int(firstarray)) print int(firstarray), ' x ', int(firstarray), ' y' self.object.rect.x = int(firstarray) self.object.rect.y = int(firstarray) initialization.platform_list.add(self.object)
What I want to be able to do is access these created sprites and move them, but if I use this code to try and move all of the sprites in the platform_list group:
if (loadterrain.character.direction == self.left): loadterrain.wall.rect.x += self.movementspeed loadterrain.object.rect.x += self.movementspeed if (loadterrain.character.direction == self.right): loadterrain.wall.rect.x -= self.movementspeed loadterrain.object.rect.x -= self.movementspeed loadterrain.floor.rect.x -= self.movementspeed
The only object on screen that will move is the last object that my for loop has created.
I want to be able to access and modify the x and y positions for every sprite inside of the platform_list but have no idea how to do so because from the research I have done indexing the platform_list is unreliable as it is not ordered.
What is the best way for me to access and modify the positions of all the sprites in that group?