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. Check a Condition


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 Back
Next arrow_forward
  1. Use an "if-then" block to make the sprite stamp only when the mouse is clicked.
  2. Make the screen clear when the code is started.
  3. Add a "when green flag clicked" block to the code.