This page is out of date

You've reached a page on the Ren'Py wiki. Due to massive spam, the wiki hasn't been updated in over 5 years, and much of the information here is very out of date. We've kept it because some of it is of historic interest, but all the information relevant to modern versions of Ren'Py has been moved elsewhere.

Some places to look are:

Please do not create new links to this page.


Particle Burst

While SnowBlossom is useful for the common falling particles, you may want to have an explosion of particles. Useful for when things are blowing up or simulating sparks from a steel on steel impact.

This is the factory class that creates the particle burst

init:
    python:

        class ExplodeFactory: # the factory that makes the particles
            
            def __init__(self, theDisplayable, explodeTime=0, numParticles=20):
                self.displayable = theDisplayable
                self.time = explodeTime
                self.particleMax = numParticles

theDisplayable The displayable or image name you want to use for your particles

explodeTime The time for the burst to keep emitting particles. A value of zero is no time limit.

numParticles The limit for the number of particle on screen.

Here is an example of how to use it.

Put the following into your init block.

    image boom = Particles(ExplodeFactory("star.png", numParticles=80, explodeTime = 1.0))

Then you can just "show boom" to show the particle burst.

Here is the rest of the code

            
            def create(self, partList, timePassed):
                newParticles = None
                if partList == None or len(partList) < self.particleMax:
                    if timePassed < self.time or self.time == 0:
                        newParticles = self.createParticles()
                return newParticles
                
            
            def createParticles(self):
                timeDelay = renpy.random.random() * 0.6
                return [ExplodeParticle(self.displayable, timeDelay)]
            
            def predict(self):
                return [self.displayable]

init:
    python:        
        class ExplodeParticle:
            
            def __init__(self, theDisplayable, timeDelay):
                self.displayable = theDisplayable
                self.delay = timeDelay
                self.xSpeed = (renpy.random.random() - 0.5) * 0.02
                self.ySpeed = (renpy.random.random() - 0.5) * 0.02
                self.xPos = 0.5
                self.yPos = 0.5
            
            def update(self, theTime):
                
                if (theTime > self.delay):
                    self.xPos += self.xSpeed
                    self.yPos += self.ySpeed
                    
                    if self.xPos > 1.05 or self.xPos < -1.05 or self.yPos > 1.05 or self.yPos < -1.05:
                        return None
                
                return (self.xPos, self.yPos, theTime, self.displayable)