MLNI – Fireworks (Billy Zou)

FireWorks

This week I developed a simulation of colorful fireworks using p5, in an object-oriented way.

fireworks

Classes 

I used two classes to implement this effect, Spark and SparkManager .

The previous one is the particle itself and the latter one is the manager of particles.

Spark

In fact, they are circles filling with different colors.

The particle has properties position, velocity, size and color. The color is totally random. In order to produce the effect of explosion, sparks close to the center are larger than sparks with higher initial velocity.

As time goes by, sparks will fall more and more quickly and at the same time, they will become smaller and smaller. Finally all sparks will disappear.

SparkManager

Basically, this class is an array of sparks and some methods to manipulate the array. In practice, this class has only one instance.

Every frame, it will update all sparks and remove sparks that are not visible. Finally it will draw all sparks. Sparks are stored in an array.

Main Process

The main process is quite straightforward. This assignment is simple, however, object-oriented-programming is what we will keep using. OOP is a powerful way to program, especially program relating to visual effects.

Leave a Reply