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. Fai sfilare i personaggi principali

Transcript

So far, the main character has only performed actions that were included in the starter project. The next two videos will show you how to create a new message and another action for the main character. First, program the main character to walk.

Click the main character to start. To make the main character look like it is walking, use the “switch costume” block. There are two walking costumes, so drag out two “switch costume” blocks. From the dropdown menus, select “Walking1” and “Walking2.” Test the code by clicking the blocks a couple times. It looks like nothing’s happening between clicks. That’s because the computer executes one instruction after the other too quickly for you to see the change. To slow it down, place a “wait” block in between the two “switch costume” blocks. Now, you can see the costumes change.

Repeat this change with a repeat loop.

Test it by clicking the code. It works, but the main character kind of looks like it’s twitching instead of walking. Read the code to understand why. It reads: “switch costume, wait, switch costume, and then switch costume again.” The program doesn’t pause before restarting the loop. Add another “wait” block after “switch to costume walking2.”

Test it. The main character’s walking looks less awkward now!

The main character looks like it’s walking, but it doesn’t go anywhere. Add some “move” blocks after the “switch costume” blocks to make the main character move while it walks.

Test it one more time! The main character walks backward! To fix that, try making it move negative 10 steps instead of 10. Now, it walks in the direction it’s facing! Have fun tinkering with this code. Change how far the main character walks by changing the number in the “move” blocks or in the repeat loop. Change how fast the main character walks by changing the values in the “wait” blocks.

In computer science, it often takes more than one try to find the right solution to a problem.

Keep coding, testing, and trying solutions until you find the one that works.

Now, it’s your turn: Use the “repeat,” “switch costume,” “wait,” and “move” blocks to make the main character walk.

Tinker with the values in the blocks until you like how the main character walks.

In the next step, you’ll broadcast a message from the narrator to make the main character walk.

arrow_backward Indietro
Avanti arrow_forward
Istruzioni
  1. Cambia costume per dare l'impressione che il personaggio stia camminando.
  2. Rallenta il cambio del costume, per dare agli utenti il tempo di vederlo.
  3. Continuare a ripetere il cambio di costume.
  4. Fai muovere il personaggio.