[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Bullet Tests
I tried building a bullet recycling system, and I don't see a big
performance boost from it -- but it's hard to tell.
If you want to check it out, see:
http://kschnee.xepher.net/code/cestus_mk2.py
http://kschnee.xepher.net/code/cestus_mk2%20(no%20recycling).py
Those are versions of the shooter game hacked to run for 500 frames with
the player being invincible and the controls disabled, and the random
number generator "seeded" so that the same enemy pattern always appears.
The weird thing is, in the first copy -- the one with recycling -- the
enemies mysteriously stop firing after a while. I put in a debug line
(currently commented out; search for "The guns -- they've stopped!") to
report on how many player, enemy, and spare bullets are in-game. That
line reports that bullets are getting recycled, all right, but the
enemies just stop shooting!
Anyway, the framerate difference I got was only something like 33 vs. 30
(recycling and not). It could be that my "graphics" and game logic are
too poor, so I tried running a test with the screen drawing disabled,
and got FPS of 38 vs. 37.
My Bullet class is really simple, though. You might get more of a
performance difference if you're using sentient 3D particle-trail
bullets with Wikipedia access.
Kris
(Bullet Bill: "*Sniff* I'm gonna miss ol' Buck -- he was a good shot!")