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

Re: [pygame] global class instances?



2007/11/24, Jake b <ninmonkeys@xxxxxxxxx>:
> (2) I'm going to be creating a sprite group: "bullet_sprites". Do you
> think my sprite groups should be global? Because I need to spawn
> bullets from within Player().

I don't know for your other question but may be really interested by
the answers.

For this point, here is what I do :
- have a class named "DisplayManager" and instantiate it
- this instance sould be global or passed to every object in the
constructor (as you do now)
- this class has a method "create_bullet" that creates the bullet with
the right sprite group. This will also be the class that handle the
"draw" method and holds the sprites group, the pygame.display...

hope that helps

-- 
Ghislain Lévêque