Also, would doing it this way require me to make Bullet inherit pygame.sprite.Sprite?
On 4/9/07, Charles Joseph Christie II <[EMAIL PROTECTED]> wrote:
That's not quite what I meant... I'm bad at describing things. Let's see... um... my drawing code uses the RenderUpdates method. At the top of the main loop, I have: all = pygame.sprite.RenderUpdates() after that, I have all the classes listed as: textsprite = Textsprite([]) the text I want shows up in the brackets. I'll be changing that later anyway. Next, I have all.add(textsprite) which makes the game update the sprites in the listed classes, in this case textsprite. A little later down, I have: all.clear(screen, background) all.update dirty = all.draw(screen) pygame.display.update(dirty) which would redraw all the sprites on the screen that have changed without updating the ones that haven't. My question is, what do I have to put in all.add to get the bullets to actually show up on screen? On Mon, 09 Apr 2007 15:38:25 -0400 Kris Schnee <[EMAIL PROTECTED]> wrote: > Charles Christie wrote: > > Now my questions are: > > > > A. If this is really all I have to do, how do I get the bullets to > > register with my screen redrawing class? I use that dirty rect > > update method where you have to specify the class with the sprite > > class. > > If you want the bullet objects to have a reference back to the object > running the game (if any), you can give them that reference. Say: > > class Game: > ... > def MakeBullet(self): > self.bullets.append(self, Bullet() ) > > class Bullet: > def __init__(self,game_object): > self.game_object = game_object > > If you do that, the bullets can then call functions of the game > object. I do that for the ships in my game so they can say, "Hey, I > got destroyed," but not for bullets. Also I've got separate lists for > player and enemy bullets to simplify collision detection.