How to bind a particle effect to an event

We have this class to make a window where we initialize the self.particles list that will contain the particles data

  • another method will populate the list with the data (called when something happens … if win:…)
  • another one (continuosly called) will move the particles changing the data
The self.particles_show() is called every frame, but it will show data

To make some particle effect, like an “explosion” create this class:

This will make the particles move and then disappear.

But, firstly, we got to create the particles data like position, color etc.

When you want the explosion to happen, you call this create function

self.particle_explosion_create(r1, c1, r2, c2)

this will be put under a condition, an if statement.

The whole code is here

Subscribe to the newsletter for updates
Post written by Avatar A python enthusiast

My youtube channel
Twitter: @pythonprogrammi - python_pygame

Higlighted videos

Speech recognition game
Pygame cheatsheets Videos about this map editor
New free game: Crystal of time
How to make a map editor 1
How to make a map editor 2
How to make a map editor 3
Map editor 1.5
Map editor 1.6
How to make a videogame map editor with Python - MEP v. 2.1
Map editor for 2d platform game in Python with Pygame v.3.0
How to save a list with pickle with python
Pygame Map Editor 4.0 for Crystals of time
Github repository
Newest branch (to clone it with git)
git clone --branch cotb2

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.