Here you go, along with a few other pieces; I’ve deleted some portions for brevity.
def __init__(self, """other params"""):
self.particleSystems = 
# Further initialisation here...
self.updateTask = taskMgr.add(self.update, "update")
self.updateTask.lastTime = 0
self.time = 0
def update(self, task):
if task.lastTime == 0:
dt = 0
dt = task.time - task.lastTime
task.lastTime = task.time
for system in self.particleSystems:
self.time += dt
def __init__(self, """other params here"""):
# Other initialisation here...
# Particles are created in __init__ and
# added to particlePool, from which they
# are taken as called for and placed in
# particlesInUse, to be returned once spent.
self.particlePool = 
self.particlesInUse = 
# Particle creation code here...
def update(self, dt, meshDrawer):
for particle in self.particlesInUse:
particle.timer += dt
if particle.timer < particle.lifeSpan:
# This would normally have particle update
# code; it has been removed to better get
# an idea of how quickly it runs without the
# additional code, such as Vector additions.
particle.active = False
self.particlesInUse = [x for x in self.particlesInUse if x.active]
# Particle spawning handled here...
def __init__(self, lifespan, frameList):
def draw(self, meshDrawer):
meshDrawer.particle(self.position, self.frame, self.size,
The above seems to run (admittedly with two other applications - Firefox included - running) at about 19 frames per second. With the particle update code reinstated it runs at about 15 frames per second, I believe.
There shouldn’t be any initialisation other than updates to the lists used for the particle pool and “active particle list”. Particle spawning involves popping a particle, setting various of its members and pushing it onto said “active particle list”. That said, I seem to recall that my PStats tests should have isolated the particle update section, and that alone seems significantly slow, so my list manipulation is unlikely to be a sole culprit.
(There is also, by the way, an OnscreenText that should be being updated every few frames, but that doesn’t seem to slow things down by more than a few frames per second.)
As to C++, as mentioned above, I have considered it, but would prefer against it if feasible. With regards the particle system, I’m more likely to look for another solution (such as using a pre-existing particle system or avoiding lots of particles) - again as mentioned above, I’m rather more concerned for my main game, since I don’t yet know how many objects I’m likely to have per “level” (I’m hoping for a fair bit of interactivity).
(Hopefully I’ll soon be in a good position to start testing the main game on such matters.)