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

Re: [pygame] Firing bullets



That's the most basic way of doing it... but reusing bullets means that
the program doesn't have to delete and recreate bullets every
operation. If I understand correctly, it only needs to make one set of
bullets.

I know that it is faster, but I'm not sure how much faster, or how much
more efficiently it will work, and if it is easier or harder to code it
that way, although the kill and recreate way sounds a bit easier to
code.

I don't know which I would be using, though... I have until the end of
April to turn in my code and art... my code is not finished, my music
isn't anywhere near done and I keep forgetting to contact my artist <_<

On Sun, 8 Apr
2007 10:29:19 -0500 "Lamonte(Scheols/Demonic)" <scheols@xxxxxxxxx>
wrote:

> 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"
> >
> 
> 
>