Skip to content

Please update your browser

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

3. Vérification de condition

Transcript

In this step, you’ll make the graffiti project interactive by enabling the user to choose where to paint his or her masterpiece. From the control menu, choose an “if/then” block. The top of the block has a space for the condition, or the thing that is being tested. For this project, the user will paint if the mouse button is pressed down, so “mouse down” is the condition for this “if/else” block. From the “sensing” menu, drag the “mouse down” block into the condition.

To make the spray paint sprite stamp only “if” the mouse is down, place the “if” block around the “go to mouse pointer” and “stamp” blocks.

Try it out!

If the mouse button is pressed down, the spray paint sprite stamps. If the mouse button is not pressed down, nothing happens.

Add a “clear” block to the beginning of your block stack to clear the stage.

Finally, add a “when green flag clicked” block.

If you get stuck, you can always ask a neighbor to help you out. Computer scientists work together all the time to help each other find and fix bugs in their code.

Now it’s your turn: 1. Make the trail appear only when the mouse button is held down using an “if/then” and “mouse down” block.

2. Clear the screen using a “clear” block. 3. Add a “when green flag clicked” block.

arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Utiliser un bloc "Si/alors" pour faire s’estampiller le lutin seulement lorsque l'on clique sur le bouton de la souris.
  2. Efface l'écran lorsque le drapeau vert est cliqué.
  3. Ajouter un bloc "Quand drapeau cliqué" au code.