🔥 Amazing explosion animation with Pygame.
An Explosion
instance is made of a set of Particle
objects. Those particles are fireballs which behavior is determined by a random generated velocity vector.
particle.velocity = [vx, vy, vz]
vx
determines how fast a particle moves to the right or to the left.
vy
determines how fast a particle moves up or down.
vz
determines how fast a particle moves closer to the screen.
The effect of making a particle going off the screen is achieved by increasing the particle radius and brightening its color.
explosion = Explosion(
particle_size, total_particles, x_expansion, y_expansion, screen.window
)
particle_size
sets the initial radius of the explosion particles.
total_particles
is the number of fireballs in the explosion.
x_expansion
sets how much the explosion expands to the right and to the left.
y_expansion
sets how high the explosion expands.
This project uses the Pygame module. You can install Pygame with:
$ pip install pygame
The main file is start_explosion.py
. You can run the animation with:
$ python -m explosion.start_explosion
When you execute the project black screen will be displayed. Just click somewhere in the screen and BOOM:boom::boom: