I want to create a few figures which only have difference in coordinates, but same in other properties. But my code allows me to control and move only last added to array figure, so what shoud I do to be able to move every figure, can you explain?
class car(pygame.sprite.Sprite):
def __init__(self,x,y):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load(os.path.join(IMG, "car.png")).convert()
self.rect = self.image.get_rect()
self.rect.x = x
self.rect.y = y
self.image.set_colorkey(BLACK) # made bg transparent
self.image = pygame.transform.scale(self.image, (70, 70))
x = 30
for i in range(8):
cars = car(x, 35)
figures.add(cars)
x += 75
if (cars.rect.y//75)+1 == y and cars.rect.x//75 == x:
cars.rect.y += 75