Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

arrow_back Celebration


In this add-on, you'll program a celebration for when the batter achieves a perfect batting average.

(high energy music)

Start by programming the celebration.

This can be any fun action or animation.

For example, you might make the stadium flash different colors using the change color effect, wait, and repeat blocks.

Or make your celebration a sound.

To add a sound to your project, click on the sound tab and click choose sound from library.

Then, choose one you like.

(slowbeat music)

(high energy music)

In your celebration, the coach could also congratulate the batter.

There are many possible celebrations.

Use the ideas here, combine them, or come up with your own.

Build the code for the celebration actions, but don't connect them to any other code or event yet.

The second part of this video will show you how to add the celebration to your game.

Once you've finished creating a celebration, test it by clicking on the code.

(high energy music)

♪Hey!♪ Now, tell the program when to run the celebration.

Click the coach sprite.

The celebration will happen after the coach sprite tells the batter the batting average.

To let other sprites know when the coach is finished talking, go to the events menu and drag out a broadcast block.

Place it after the coach says the batting average.

Click on the drop-down, then select new message and give it a name like celebration.

Next, program the celebration code to receive that message.

If multiple sprites or the stage have blocks, you'll complete these same steps for all of them.

From the events menu, place a when I receive block above the code for your celebration.

Click the drop-down and select the name of your message.

Test the code.

After 5 pitches the coach says the batting average, then the celebration happens.

(high energy music)

But the celebration is only supposed to happen if the batter got a perfect score.

From the control menu, place an if then block around the broadcast block.

Fill out the condition.

If the batter got a perfect average, the batting average will equal 1.

From the operators menu, place the equals block in the if then block.

To check if the batting average equals 1, type 1 on either side of the equals block.

The other side will contain the batting average.

Right-click on the batting average equation in the say block and select duplicate.

Place the duplicate code in the other side of the equals block.

Test the code.

Practice batting until you get a perfect batting average.

When the coach says your batting average is 1 the celebration should begin.

(high energy music)

Alright, here's the game plan.

First, program the celebration.

Then, use the broadcast and when I receive blocks to let Scratch know when to make the celebration happen.

Finally, place the broadcast block inside an if then statement.

Use the equals block and copy the hits and divide blocks to create the condition.

Choose an Add-On
Program a celebration for when the batter achieves a perfect batting average.
Over the Plate
Make the baseball look more realistic as it approaches or moves away from the plate.
High Score
Tell the batter if it has beaten the best batting average so far.
Going through the Motions
Animate the pitcher so it looks like he or she is moving.
arrow_backward Back
Next arrow_forward
  1. Choose an add-on and click "Watch" to learn how to customize your project.
  2. When you finish, come back to the add-ons screen, and try another add-on!