Final Project for Coding (Explosions)

Alexander Chan
2 min readApr 29, 2021

What inspired it?

I struggled with making the particles spread out once they reach the top and implementing the physics of the fireworks to come down with gravity as well having it update and then remove after an explosion.

What challenges did I face?

So I had to make two different types of classes Kaboom and Particles.

What is the logic behind your code at a high level?

Particles class is for all the particles that explode. It has an constructor for the position, velocity, magnitude, acceleration and angle of which forms the shape of the explosion of particles. Then a show function checks for the acceleration that is decreasing from 1 to the absolute of 0.35 after it is decreased it makes the particles with colors. This also has an update function that sets the acceleration and increases it as well as the velocity and position.

Kaboom has the physics of moving the the firework into the air with the velocity, magnitude and acceleration. This also creates an array of particles that check if the explode function has occurred in a if statement, so if it has not occurred it will send the rocket into the air and once it hits 0 velocity which is the peak it has an else statement to have the particles class show and update.

What was the most interesting thing you learned while making it?

The most interesting thing I learned was the physics of making the particles explode and adding functions that change it. It was fun to figure out how to make some shapes when exploding it and experimenting with that.

References:

https://editor.p5js.org/arthurrc/sketches/B1xQznnjQ

//Similar type of code ^^

//By Daniel Shiffman

Final version (below) — Alexander Chan

--

--