Fireworks

The goal
Step 1. Set the stage
Step 2. Delete the cat
Step 3. Create the 4 sprites
Step 4. Sprite 1 Fireworks
Step 5. Sprite 2 Fireworks
Step 6. Sprite 3 Fireworks
Step 7. Sprite 4 Fireworks

The Goal

When you click the green flag, the project creates fireworks of various shapes.

Step 1. Set the stage

Make a new project. Then change the color of the stage to black. Can you figure out how to do that?

Step 2. Delete the cat

Delete the cat sprite. Hint! Use the scissors tool. Can you figure out how to do that?

Step 3. Create 4 sprites

The Fireworks project has 4 sprites, each of which creates a different kind of firework.

Sprite 1:

Sprite 2:

Sprite 3 has two costumes. Here’s costume 1:

And here’s Sprite 3 costume 2:

Sprite 4 consists of 3 gray dots:

Step 4. Sprite 1 Fireworks

Here’s a movie that shows Sprite 1:

Begin by clearing the screen to remove any previously-drawn fireworks.

Now, add a forever loop. Inside the loop, you’ll tell Sprite 1 to…
* hide
* wait for a random period between 3 – 6 seconds
* go to the bottom of the screen, but at a different horizontal position each time (hint! what’s changing — x or y?)
* change its color randomly each time
* set its size to 100%
* show

Here are the commands you’ll need. (You’ll need to change the order of the commands and the numbers inside them. You’ll also need to repeat some commands.)

Now you need to create a 2nd loop inside forever, this time using the repeat command. Make sure to repeat this loop a random number of times between 40 and 80. The sprite should move upward (x or y?) in each loop, and also increase its size. Here are the commands you’ll need. (You’ll need to change the order of the commands and the numbers inside them. You’ll also need to repeat some commands.)

That’s it for Sprite 1. Onto Sprite 2!

Step 5. Sprite 2 Fireworks

If you created Sprite 1 successfully, you have all the information you need for Sprite 2. The movie below shows what Sprite 2 looks like. Can you figure out how to make it?

Step 6. Sprite 3 Fireworks

Here’s a movie that shows Sprite 3:

Sprite 3 begins by drawing a vertical line. The commands for drawing this line are almost exactly like the scripts for Sprites 1 and 2. (There are just two differences.) Based on that information, can you figure out how to draw the vertical line?

Because Sprite 3 has two costumes, you’ll need to tell the sprite which costume to use when it begins. Add a command to your script to tell the sprite to select Costume 1 when it begins to draw the vertical line.

After the vertical line is drawn, Sprite 3 switches to its 2nd costume and then draws the crown of fireworks. For this part of the script, you’ll need to create a variable that will control how fast the spikes in the crown fall downwards. You can name the variable anything you like. In the pictures below, I’ve called it yvel (y-velocity). Set yvel (or whatever you called your variable) to 0.

Then change the size of Costume 2 to 1% of its full size. The size will increase over and over, as the crown grows. You’ll need the following commands:

Now, create a loop using the repeat command. The loop should repeat 50 times. Each time it repeats, Sprite 3 increases in size a little bit. And also, the yvel variable decreases by a very small amount. (Hint! Negative numbers like -0.04 work well.) Finally, you should use the yvel variable to change the vertical position of Sprite 3 in each loop as well. (So if yvel is -0.04 the first time, the crown will fall downwards by 0.04 steps in that first loop. In the next loop yvel could change to -0.08, and the crown should then fall downwards by 0.08 steps.)

Here are the commands you need to complete this sprite (you’ll need to change the order of the commands and the numbers within them):

Step 7. Sprite 4 Fireworks

Here’s a movie that shows Sprite 4. You’ll see that the 3 gray dots in Sprite 4 pick a location either at the left or right, with a different vertical position (height) each time. Then they briefly rise upwards before falling.

You’ll need to create 3 variables like the ones below.

Begin your script by creating a forever loop. The forever loop should start by hiding Sprite 4. Then it should wait a random number between 3-6 seconds. It should set l or r to a random number between 0 and 1; in a moment, we’ll use this variable to choose whether the sprite appears at the left or right. Then it should show Sprite 4. You’ll need the commands below (you should change the order of the commands and the numbers within them):

Now you’ll need an if command. If l or r is 0 then Sprite 4 should go to the left side of the screen and grow outwards from there. Otherwise, Sprite 4 should grow from the right. You’ll need the commands below. The numbers are correct in these commands (you won’t need to change them). Why is the value of x move a positive number when the value of x position is negative (and vice versa)?

Sprite 4 now grows upwards for a bit. You’ll need commands like the ones below. These commands tell Sprite 4 to move upwards by yvel2 and sideways by x move 4 times. The numbers are correct in the commands except for change x and change y.

We’re almost done! You need one more loop using the repeat below. You’ll need to figure out the commands that go inside the repeat. (Hint: they’re very similar to the commands in the repeat 4 times loop above!)

. . .

Have fun!


This project is based on the work of johndo77 at http://scratch.mit.edu.

Return to Drawing Page | Return to Home Page