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

Re: [pygame] Firing bullets



Im a noob & all but why not just fire the bullet and destroy it when it hits the object or hits the outside of the window size(max width,max height)?

On 4/8/07, andrew baker <failrate@xxxxxxxxx> wrote:
I absolutely have profiled using lists and creating/destroying
instances.  Using freelists is always faster if you have enough RAM.
This amount of RAM is well within reasonable limits.  I always develop
for low-end machines, so my minspecs are usually tiny.
Recycling is not particularly difficult if you use a factory.
EX.

def fireBullet(mVector):
      if returnVal = unfiredBullets.pop():
         return returnVal
      else:
         return Bullet(mVector) # produces a new Bullet object

On 4/7/07, Greg Ewing <greg.ewing@xxxxxxxxxxxxxxxx> wrote:
> Kris Schnee wrote:
>
> > I'm not
> > sure that the recycling method is really necessary, if you find it hard
> > to program. (It's probably not hard; just laziness on my part that I
> > didn't use it.)
>
> I suggest measuring before concluding that keeping a
> free list is faster. It might not be.
>
> > -Is it worth using ODE physics for bullets? ... But you'd also have the
>  > overhead of constantly being notified about bullet-on-bullet collisions,
>
> Not necessarily. ODE geoms can have a bitmask that
> determines what categories of objects collide with
> others. So you could easily arrange for bullets to
> collide e.g. with players and walls but not with
> each other.
>
> --
> Greg
>


--
Andrew Ulysses Baker
"failrate"



--
Join phpdiscovery.com Now!