Hi,
I've dabbled in some programming in the past, but nothing serious. I'm trying to create an array of objects in python 2.6 (VPython).
What I want to do is create a 2d grid of sphere()'s. But I want to be able to manipulate each one individually after they are created. So what I would like to end up with is a set of objects like:
ball1=sphere(x=x1, y=y1, z=0)
ball2=sphere(x=x2, y=y2, z=0)
..... etc.
My first thought was to do a nested pair of FOR loops
for i in range (0, 100):
for j in range (0, 100):
ballij=sphere(x=i, y=j, z=0)
but I can't figure out how to set up the variable so that it creates a unique variable for each iteration that I can address each sphere. Basically, I can't figure out how to set up "ballij". Not sure if it's even possible in Python. I've done it before in a specialized scripting language based in fortran though.
So someone suggested using an array. But I'm not sure how that would be set up. If it was just an array of numbers, that would be simple, but not sure how to do this.
Any ideas.