Skip to content

Please update your browser

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

4. Many Falling Objects

Transcript

With just one object falling, the game is pretty easy.

This video will show you how to make copies, or clones, of the falling object.

Click on the blue star.

In the “control” menu, find the block that creates clones called “create clone of myself.”

Drag this block into your scripts area, separate from the code that makes the object fall.

Click on it.

It looks like nothing happens, but when you move the object, you’ll notice there’s a copy under it.

Next, make the copy fall as soon as it is created.

From the “control” menu, place the “when I start as a clone” block at the top of the code stack that makes the object fall.

To test this, click the “create clone of myself block.”

A copy of the object should appear at a random location at the top of the screen, then fall.

It does!

To make more than one falling clone, add a new “forever loop” around the “create clone of myself” block.

Test the code by clicking on the forever loop.

Woah!

That’s way too many clones!

The game would be too hard with this many objects falling, plus your computer might crash trying to keep track of them all!

Slow down the creation of clones by adding a “wait” block inside the loop that creates the clones.

Make the game more unpredictable by adding a “pick random” block inside the “wait” block.

Make the wait time between clone creation as short or as long as you’d like for the game you’ll play with your friend! Tinker until the game works the way you like!

Place a “When flag clicked” block above the clone-creating forever loop.

There’s still a lot of clones for your computer to keep track of, and the game only needs to keep the clone until it hits the ground.

From the control menu, drag out the “delete this clone” block.

“Delete this clone” makes the clone go away.

The clone should disappear if it touches the bottom of the stage.

It can tell it has touched the bottom of the stage if it touches the green grass color.

From the control menu, choose an “if” block, and place it around the “delete this clone” block.

From the sensing menu, place a “touching color” condition inside the “if” block.

To make sure the right color is selected, click on the color in the box, then click on the green grass at the bottom of the screen.

The box should change to green.

Put this “if” block inside the forever loop that makes the object fall.

Now, that code reads, “When I start as a clone, go to a random spot at the top of the screen, then fall.

If I touch the green grass color, delete myself.”

Test the code by clicking on the green flag.

Objects should fall from the sky and disappear when they hit the ground.

Great!

Finally, hide the first object.

It is not a clone, so it is not programmed to fall.

It just hangs out at the top of the screen!

To hide it when the game starts, place a “hide” block under the “when flag clicked” block.

This would also hide the clones, so place a “show” block under “when I start as a clone.”

Test by clicking the green flag.

Awesome!

The first object hides, but the clones show and fall.

Now it’s your turn: Create clones using the “create clone of myself” and “wait” blocks inside a forever loop.

Make the clones fall by adding a “when I start as a clone” block.

Delete the clones when they touch the green ground.

Add a “when flag clicked” block to the top of the block stack.

Hide the original object, and show the clones.

arrow_backward Back
Next arrow_forward
Instructions
  1. Create clones using the "create clone of myself" and "wait" blocks inside a forever loop.
  2. Make the clones fall by adding a "when I start as a clone" block.
  3. Delete the clones when they touch the green ground.
  4. Add a "when flag clicked" block to the top of the block stack.
  5. Hide the original object, and show the clones.