[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Re: Creating several instances of same image



David J. C. Beach wrote:

On Mon, 2004-07-26 at 19:50, Daniel Dornhardt wrote:

Grant Morganryuuguu wrote:


Also you could use a Numeric array. I like them for 2d structures

<snip!>

FORGET Numeric. You don't need it to do that... for what you're doing,
a dict-of-tuples is just as effective.

x = 3
y = 4
aliens = { }
for i in range(x):
for j in range(y):
aliens[i,j] = Alien((LEFT + i * DISTANCE, TOP + j * DISTANCE))

Dave


at least now i have some alternative ideas for more-dimensional arrays... look what i did some time ago...

def array2d (x, y, value=0):
array = [None] * x

for z0 in range (x):
array[z0]=[value]*y

return array

def copyarray2d(array):

size=[len(array),len(array[0])]
copy = array2d(size[0], size[1])

for z0 in range (size[0]):
for z1 in range (size[1]):
copy[z0][z1] = array[z0][z1]

return copy

i, personally, still wonder about python lacking a multi-dimensional array language construct...