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

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



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

import Numeric
x=3
y=4

aliens = Numeric.resize(Alien(),(x,y))

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

I find it easier to visualize what the code is doing when I can use [i,j] type syntax.  Also you can use slices to find left most and right most alien which you will need.

On Mon, 26 Jul 2004 20:43:39 +0200, James D. Kirk <frozensound@gmx.de> wrote:

> alienList = []
for z0 in range( COLUMNS ):
for z1 in range (ROWS ):
alien = Alien((LEFT + z0 * DISTANCE, TOP + z1 * DISTANCE))
alienList.append(alien)

... should read:

alienList = []

for z0 in range( COLUMNS ):
for z1 in range (ROWS ):
alien = Alien((LEFT + z0 * DISTANCE, TOP + z1 * DISTANCE))
alienList.append(alien)

of course.