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

Re: [pygame] Never seen this before



Okay, I had assumed you had written your own python class, subclassing one of the Group classes, and had used .add within the overridden method. I've made that mistake myself.

Looking at your code, I see the issue. For one, Group.add takes in a list of sprites. You are passing in three separate arguments, and Group.add is thinking they are each sprites.

You should change
 enemies.add(random.choice(("enemyblue.png", "enemycyan.png", "enemygrey.png", "enemyyellow.png")), item, enemybullets)

to
enemies.add(Enemy(random.choice(("enemyblue.png", "enemycyan.png", "enemygrey.png", "enemyyellow.png")), item, enemybullets))


The super method can take a class and an object as parameters, and it will call the method on the superclass of the class given. It is the same as
Basicsprite.__init__(self, img)

For reference, here is the documentation about Group.add:

http://www.pygame.org/docs/ref/sprite.html#Group.add

-Tyler

On Sat, Apr 25, 2009 at 6:34 AM, Yanom Mobis <yanom@xxxxxxxxxxxxxx> wrote:
the two files for the game are attached

--- On Fri, 4/24/09, Brian Song <unlucky777@xxxxxxxxx> wrote:

From: Brian Song <unlucky777@xxxxxxxxx>

Subject: Re: [pygame] Never seen this before
To: pygame-users@xxxxxxxx
Date: Friday, April 24, 2009, 9:57 PM


 If the problems fixed, yay. If not, you should put up most/all your source so it's easier for people to see whats happening.




--
Visit my blog at http://oddco.ca/zeroth/zblog