vendredi 31 octobre 2014

How is it possible to make multiple rectangle instances in Pygame?


Vote count:

0




I'm trying to create multiple rectangles using a for loop with PyGame but I'm not really clear on how I could do this. My first approach was storing all rectangle instances in an array but then I ran into another problem, how to assign a .get_rect() to it. So I did this:



def MultiRect(amount):
objects = []
objectsRect = []

for i in range(0, amount):
objects.append(pygame.Surface([200,100]).convert())
objects[i].fill((130,130,130))
objectsRect.append(objects[i].get_rect())


So what I tried to do was make two arrays, one stores the instance and the other stores the instance.get_rect() but I know this is the wrong way to do it and I also get multiple out of range errors. Is there another way I could go about this?



asked 48 secs ago

Toby

11






How is it possible to make multiple rectangle instances in Pygame?

Aucun commentaire:

Enregistrer un commentaire