Skip to content

Please update your browser

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

2. Mouvement


In this video, you will program your sprite to move, bounce off the edges of the stage, and point towards the mouse pointer. Your starter project begins with the sprite, Tera. To make Tera move, select the motion menu, and pull out the “move 10 steps” block. Clicking it will make the sprite move 10 steps. Tinker with the value to make the sprite move a little or a lot. Notice that if the value is negative, the sprite moves in reverse! Right now, the sprite only moves 10 steps once when you click the block. But, for this project, Tera should move constantly. Go to the control menu, and pull out a forever loop. Place it around the “move” block. Now, when you click the block stack, Tera should constantly move until it moves off screen!

Using only the forever loop and the “move” block, Tera is not programmed to either stop or turn around. To make Tera turn around when reaching the end of the stage, place an “if on edge, bounce” block inside the forever loop. When you test it, the sprite should bounce back and forth across the screen. This is a great effect, but Tera also needs to be able to change direction and follow the mouse pointer. Fortunately, there is a block for that! From the motion menu, pull out the “point toward mouse-pointer” block, and add it to the stack. Now, when you test your program, Tera should always move toward the mouse pointer, but never move offscreen. Now, it’s your turn.

1. Use the “motion” and “control” blocks to make Tera always move, but never move offscreen. 2. Make Tera follow the mouse by using the “point toward mouse-pointer” block.

arrow_backward Retour
Suivant arrow_forward
  1. Utilise les blocs Mouvement et Contrôle pour programmer Tera à se déplacer continuellement sans jamais sortir de l'écran.
  2. Fais en sorte que Tera suive le pointeur de la souris en utilisant le bloc "S'orienter vers pointeur de souris".