Simple fireworks are very simple, it’s a 2 dimensional particle effect. In computer graphics, particles are usually pixels or maybe very small circles that you throw around on the screen and that move according to some plausible (usually physical) laws. In this case, we draw little circles with 5 pixel radius, and they have a position, a velocity, that we add to the position in every frame and that we also modify every frame with an accelerating force that is simply the gravity constant. When particles are created, they are placed evenly on a circle, but each of them gets their own random color. After a particle leaves the boundaries of the screen, we delete it. As a final touch, after each redraw of the particles we don’t clear the screen, but blur it for the particles to have “smoke trails”. In older programming languages managing the memory where the particles were stored was an issue (probably the hardest one for this effect), but in java, we have ArrayList and iterators, so we can spare this trouble.
