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

Re: [pygame] Firing bullets



Charles Christie wrote:
Alright, so where'd firedBullet come from, and I know that I have to use pygame.time.get_ticks() to say how long a bullet lives but I don't know how to make it so that they die after a certain amount of time... Do I declare that in the bullet class or in the main loop or what?

Here's what I have so far (It's not anywhere near done in any sense of the word. I still need characters, bullets and a scrolling background in order of importance).

Ignore the badly named files, classes and game name. :P

    On 4/1/07, *andrew baker* <failrate@xxxxxxxxx
    <mailto:failrate@xxxxxxxxx>> wrote:

        When you need a bullet,

        firedBullet = bullets.pop()

        When that bullet "dies",

        bullets.append(firedBullet)




Couldn't you use self.kill()? Wherever the timer is, you could say either self.kill() or have a variable self.bullet() and kill() that?