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 Tremblement de terre

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.

Choisir une extension
Réaction face aux éclairs
Dans cette extension, tu vas programmer les personnages dans ton histoire pour qu’ils réagissent lorsque les éclairs frappent.
Dessiner et animer un éclair
Dans cette extension, tu vas dessiner et programmer un éclair contrôlé par l'utilisateur qui glisse du ciel vers le sol.
Le soleil brille
Dans cette extension, tu vas programmer une deuxième scène pour ton histoire sous une journée pluvieuse.
Tonnerre
Dans cette extension, tu vas jouer des sons de tonnerre et de pluie dans ton histoire.
Tremblement de terre
Dans cette extension, tu vas programmer un tremblement de terre pour vraiment secouer ton histoire.
Coder un arc-en-ciel
Dessine un arc-en-ciel et programme son apparition dans ton histoire sous la pluie !
arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Choisis une extension, et clique sur "Regarder" pour découvrir comment la créer.
  2. Une fois que tu as terminé une extension, essayes-en une autre !