Skip to content

Please update your browser

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


In this video, you’ll learn how to make it look like the character is moving towards or away from the door. Start by programming the character to move.

Drag out a “move ten steps” block. People don’t walk without moving their feet.

Several Scratch sprites come with different costumes that make it look like they are walking the way people do.

To check if the sprite you chose is one of them, click on the costumes tab. This example uses the Scratch cat, who can switch between these two costumes to look like it’s walking.

If you did not choose a walking sprite for your story and you would like one, click on “choose new sprite from library,” then the walking menu. To copy your code from one sprite to another: Now, you can get rid of the old sprite and use a walking sprite instead. To make use of the walking costumes, you need to switch between them. To do that, go back to the scripts tab. Click on the looks menu, and find the “next costume” block. Click on it to switch costumes.

To keep switching costumes without clicking the block over and over, place it inside a repeat loop. To move while switching costumes, place the “move” block inside the repeat loop as well. Test the code. Now, it looks like the character is walking as it moves in a direction. But, you want the character to walk toward the door and go through it if a certain condition is met. To make that happen, Place the code below “if answer = yes” and above “switch backdrop to.” Test the code.

If you answer “should I go through the secret door” with “yes,” the sprite should walk towards the door. It does. If the answer is “no,” the sprite should move in the other direction. The code to make the character walk in the other direction is the same, so duplicate the walking code you made already.

Before the character walks, though, it needs to change direction. That is where the “point in direction” block comes in handy. “Point in direction 90” faces the sprite right. You want the sprite to walk left, away from the door. Place the “point in direction” block above the copied walking code. Click on the dropdown, and switch it to negative 90. That should point the character in the opposite direction. Click on the block to test it.

Wait! The main character is upside down! That is because of how the character is rotating, or turning. The “set rotation style” block will fix this.This sprite should only turn left or right. Click on the dropdown menu, and select “left right.” Now, click on the block. The character should only face left or right. You’ll notice that it turned right-side up. To make sure it stays that way, place this block at the beginning of this character’s code, just below “when green flag is clicked.”

Place the walking code in the “else” section of the “if answer = yes” block. Test your code again. Try saying “no” when the code asks if you want to walk through the door. The character should walk away from it. Then, try the code, but enter “yes” instead.

What!? The character still goes left. This is because the character continues to move in the direction it was last told to go. To make the character move right, place another “point in direction” block above the walking code in the “answer = yes” section. Click on the dropdown menu to make sure it is telling the character to go right.

Test the code by clicking on the green flag. Type “no” first, and watch the character walk left. Then, type “yes,” and watch the character move right. Nice job!

So you can control where the character goes, it should always start in the same spot. Pick a spot where you want the character to start, and drag your sprite there. Then, place a “go to x y” block under the “when green flag clicked” block so that the character will always start in that spot. Test your code by clicking the green flag. It works!

Tinker with the values in the “move” and “repeat” blocks to change how far the character moves.

Choisir une extension
Dans cette vidéo, tu vas découvrir comment créer l'effet que le personnage marche en direction de la porte ou s'en éloigne.
Quel est le mot de passe ?
Dans cette extension, tu vas programmer un mot de passe secret que l'utilisateur devra taper pour pouvoir franchir la porte secrète.
Faire tomber la pluie
Dans cette extension, tu vas apprendre à utiliser le sac à dos pour ajouter la pluie de ton projet de l'activité 3 dans ce projet.
Trouver la porte secrète (défi)
Dans cette extension, tu vas programmer le personnage principal pour que le public puisse utiliser les touches fléchées pour trouver la porte secrète.
Ajouter un autre lutin
Dans cette extension, tu vas ajouter d'autres personnages à ton histoire.
Ajouter une autre scène (défi)
Dans cette extension, tu vas être invité à ajouter une autre scène et tu recevras des idées sur la façon de la programmer.
arrow_backward Retour
Suivant arrow_forward
  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 !