Project #8: Fireworks
Write a program that creates fireworks with the click of a mouse



  • Write a program that has one gamestate that allows the user to generate fireworks by clicking on the screen.

  • The user should be able to left, middle, or right click on the screen and generate one of three corresponding types of fireworks. A firework must have at least one "unique" feature that is more than just a numerical change. Consider variation on things like:

    • Having fireworks with distinct explosion patterns and shapes

    • Having a firework that fades over time by changing the alpha value

    • Having a firework that changes color over time

  • Each type of firework must have its own Particle Class to represent one bit of that firework. For example, they might be called things like "DazzlingParticle" or "GreenParticle."

  • Each particle should be stored in an ArrayList of particles.

    • Note: You're allowed to use inheritance if you're comfortable with it, but we haven't officially learned this yet. That means you'll likely have three separate ArrayLists to manage. I recommend starting with a single particle type and a single ArrayList.

  • Your program must display a counter for the number of particles currently visible on the screen.

  • When a particle leaves the screen or fades from view entirely, it must be removed from the ArrayList



    1. Create your project, it should have Main, a Game state, and a Particle class.

      • The particle class should be simple and just display a small white circle

    2. Create an ArrayList of Particles

      • This is similar to how we made an array of Stars in Screensaver

      • Declare the ArrayList at the top of the class

      • Initialize the Arraylist in init

      • Tell it to update each particle every frame

      • Tell it to render each particle every frame

      • In the mousePressed method, add one Particle to the ArrayList

    3. Make the program Work

      • Improve the Particle Class

      • Have multiple particles spawn on a left click

    4. Display the number of particles on the screen

    5. Remove particles that have gone off screen or faded

    6. Add two additional types of Fireworks

      • This will require three ArrayLists, unless you use inheritance

      • Make sure to update your count to handle all three Arraylists