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

Re: [pygame] Firing bullets

I always like to fill a list full of bullet sprites to pull from when
a character is firing and to return to when they are "dead".  This
saves a lot of processing power, because you are performing less
instantiation and destruction.  The trade-off is in memory, but this
shouldn't be significant.  The only other thing I would mention is to
make sure that the bullets in the bullet sprite queue are not calling
their update, as they are inactive until fired.

On 3/28/07, Damien Miller <djm@xxxxxxxxxxx> wrote:
On Mon, 26 Mar 2007, Charles Christie wrote:

> Well, I'm trying to get my program to fire bullets now. Isn't that great?
> I think I'm doing it all wrong though...
> My problem has been that I don't know how to make the program fire bullets.
> But then I thought, "shouldn't the character be firing the bullets, not the
> program?" and it's then that I realized why I couldn't do anything. My logic
> has been completely wrong. Again. Go figure <_<
> Well, I still don't have images for characters yet and I still have no
> movement code (I should probably work on that, huh?) but everything else
> aside from the characters and bullets is done.

A few years ago I wrote some classes for an unfinished game that handled
guns and bullets. You might find them useful.


See gun.py in the distribution. It includes a basic damage system and
XML schema to describe models. It is nowhere near as capable as BulletML
(which looks amazing cool) but it is very simple and easy to understand.

The game runs, but lacks sound levels, boss logic and lighting effects.
It requires PyOpenGL.


Andrew Ulysses Baker