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

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



Jasper Phillips wrote:

On Mon, 26 Jul 2004, James D. Kirk 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)

What about:

def offset( x, y ):
return (LEFT + x * DISTANCE, TOP + y * DISTANCE)

alienList = [Alien(offset(x,y)) for x in range(COLUMNS) for y in range(ROWS)]

-Jasper

???
does it work? :D
i pseudo-tried it, it works, cool
it surely makes the whole process clearer and much easier to grok (but not for me...)
why does it work?

that's just what popped up in my head, though...

Daniel