# CPSC 120: Lab Assignment 4

### Due at 2:59 pm on Friday, 11/08/2013

Home | Announcements | Assignments | Example Code

### Overview

• Learning Processing, Chapter 9 (Arrays).

## Fireworks

Create a scene with the following elements:

• A night-time sky. Add a moon and a few stars, in whatever way looks most pleasing to you.
• A simple foreground, in the style of the cannon game from Project #1
• A fireworks launcher, on the ground, in the middle of the screen.

The launcher should send up a rocket that should

• Rise into the air with some initial velocity that is eventually overcome by gravity, arcing very slightly to the left or to the right (see the projectile motion work from our first project: you need to launch with an angle just barely less than or more than PI/2. For some variety, try choosing the angle randomly.
• At some point just barely after the top of the projectile's arc, it should explode into fireworks, which then rain down to the ground and disappear after a set amount of time.
• As the individual particles fall, they shrink in size, until they disappear entirely.
• When the last particle has disappeared, another rocket should fire.

The "rocket" is really a collection of particles, which all travel upwards together until the explosion time, at which point, their individual velocities propel them away from each other.

This is definitely a job for an array, in fact several of them. Keep arrays to record the following information for each particle:

• the x-coordinate
• the y-coordinate
• the horizontal (x-component) velocity
• the vertical (y-component) velocity
• the size of the particle

### Turn In:

As with all assignments for this course, submit the folder containing your Processing sketches. This should be a single folder named "hw4", which will contain your fireworks sketch. You do not need to submit a paper printout of anything. Again, the turnin directory is