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 Falling Rocks


In this add-on, you will make random rocks fall from the sky.

The hero has to be quick to avoid getting smashed!

Make a new sprite.

There are rocks in the Scratch library, or you can draw your own.

Then, program the boulder’s motion.

Drag out a “go to" block, and set the y to 180, then into the x blank, drag a “pick random” block.

Tinker with the values in this block to change where the boulders show up.

The example uses negative 100 and 240, so the boulders can appear anywhere in front of the hero!

Click the block stack a couple of times to test.

See that the boulder jumps to different starting places!

Next, program the boulder to descend.

In this example it will fall at a constant speed.

Put a “repeat” loop below the “go to” block, then put a “change y” block into it.

To fall, the boulder has to go in the negative y direction, so put negative 10 or another negative value into the “change y” block.

You can always tinker with this value later to see how it changes the boulder’s behavior.

Click to test.


It started out right, but it stops too soon.

The top of the stage is where y equals 180.

At the bottom of the stage, y equals negative 180.

If you’re in the middle, you can go 180 in either direction, which means the height is two times 180, which is 360.

To figure out how many times to descend, divide 360 by the distance the sprite moves each time.

In the example, it moves by 10 steps each time.

360 divided by 10 is 36, so type 36 into the repeat loop.

Test it again.

It stops right where it should.


Snap a “when I start as a clone” block at the top of the block stack and a “delete this clone” block at the bottom.

Test it out by clicking “create a clone” in the “control” menu.

The boulder should also do some of the same things the bug does, so click on the bug and copy some code over.

Right click the “hide” block under the “when flag clicked” block, click duplicate, then drag that block stack to drop it on your new boulder sprite.

That gives you a copy of just that part of the code, which is what you need.

Click back to the boulder.

Get a “when flag clicked" block, and snap it onto the stack that starts with “hide.”

That will make the boulders appear randomly just like the bugs.

Also add a “show” block to the top of the “when I start as a clone” stack.

Test all your new code by clicking the flag.

See if the boulders fall!

See if you can run away from them.

You can’t!

Add some code to fix that.

If you look at the ground or the cloud sprite, you’ll see they both receive the “forward” message.

The cloud looks a little simpler.

You’ve probably seen it floating by as the hero moves.

Use the same concept to make the boulders move.

In fact, in the spirit of reusing code, go ahead and drag that block stack to the boulder sprite.

The parallax activity discussed how things that are farther away appear to move slower, which is what the cloud does.

It moves 5 steps for every 10 steps the ground moves.

Since the boulders are falling right on top of the ground, they should move as fast as the ground, so type negative 10 into the “move” block.

The rest of the stack was for making the cloud sprite restart on the right side of the stage, which a boulder shouldn’t do, so discard it.

If everything works, you're done. Good work animator!

Now, it’s your turn.

Program the boulder to go to a random spot at the top of the stage, then fall.

Use code from the bug to make random clones of the boulder Copy the code from the cloud to make the boulders respond to the hero’s movement.

Choose an Add-On
Game Over
Give your hero a set number of lives.
Program your hero to shoot lasers to vanquish the evil bugs.
Add a power pellet to make the hero jump higher.
Falling Rocks
Add a falling obstacle to your game.
The terrain of your game will change to move up and down.
Follower Friend
Add a cute buddy who follows your hero around.
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!