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 Earthquake

Transcript

At this point, you should have built a story that takes place in a stormy day setting.

In this add-on, you’ll broadcast an earthquake to really shake up your story.

First, you’ll need to find a way to make the earth shake.

Click the earth sprite, and select the motion menu.

For this earthquake, you’ll program the earth to move left and right repeatedly. To do this, you’ll need blocks that move the sprite left and right, and a way to make them repeat that motion. Drag out two “change x by” blocks. X coordinates represent left and right positions on the screen, so if you change the x position of a sprite, you’re moving it left or right. Also, make sure to use the “change” blocks, as the “set” blocks won’t allow you to continually move the sprite.

Click one of these blocks. Great, the sprite moved right.

To move the sprite left, change the other block to a negative number.

Perfect! Now you have a way to move the earth sprite left and right. Next, program the sprite to perform that action repeatedly. Click “control,” and drag out a “repeat 10” block. Put the two “change x by” blocks inside the “repeat 10” block. Click this block stack to try it out. Oh no!

Nothing happened! That’s because this code runs so fast that you can’t see what it does. To fix this, add two “wait” blocks to your code to make the program pause after each left and right movement of the earth sprite.

Try it out! Well, you can see it moving now, but it’s way too slow! Make it faster by shortening the wait times. Great! How about making it a little longer, though? Try repeating it something like 30 times.

Nice! That looks like a good earthquake.

Tinker with these numbers until you have an earthquake that you like.

Finally, you need an event to tell the computer when to run this code.

If you want the earthquake to happen in the middle of your story, you’ll need to broadcast an event to make that happen. Drag out a “broadcast” block, and place it in a spot in your story where you’d like the earthquake to happen. Change the message name to “earthquake.” Click back to the earth sprite, and add a “when I receive earthquake” event. Awesome, try it out!

Consider continuing to build your story events around this earthquake. What might happen after the earth starts shaking? Now, it’s your turn: 1) Use “change x by” blocks to program the earth to move left and right.

2) Use a “repeat 10” block and “wait” blocks to make the earth appear to shake.

3) Broadcast the earthquake in your story, and use a “when I receive” event to make sure it happens.

Finally, consider building your story around this new plot event.

Choose an Add-On
Lightning Reaction
In this add-on, you’ll program the characters in your story to react when the lightning strikes.
Drawing and Animating a Lightning Bolt
In this add-on, you’ll draw and program a user-controlled lightning bolt that moves from the sky to the ground.
Sun Comes Out
In this add-on, you’ll program a second scene for your rainy day story.
Playing Thunder
In this add-on, you’ll play thunder and rain sounds in your story.
Earthquake
In this add-on, you’ll broadcast an earthquake to really shake up your story.
Code a Rainbow
Draw and program a rainbow to appear in your rainy day story!
arrow_backward Back
Next arrow_forward
Instructions
  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!