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. Decide What to Stamp


In this video, you will program the scanner sprite to stamp the black color where the stage is black, and the white color everywhere else.

The scanner sprite’s selected costume determines which color it stamps the background. This starter project has two costumes that are different colors: white and black.

In order to make a shadow, the computer needs to decide when to change the sprite’s costume to stamp the correct color. To make that happen, go to the control menu, find the “if-else” block, and place it just above the “stamp” block in the code.

This block creates a decision so that when the code is run, the computer does one thing or the other--not both! Make sure that the stamp block goes beneath the if/else block you just put in the stack For today’s project, the decision is based on whether or not the sprite is touching the color black. Go to the sensing menu, pull out the “touching color” block, and place it inside the “if-else” block.

Now the block reads “if touching color,” but the color isn’t black. To make the color black, click on the box in the “touching color” block. You should see a little, white hand. Then, click on the color black in the stage. Now, the “if/else” block will check each pixel to see if it is black.

Next, tell the sprite what to do when it touches black. It should stamp the color of its costume, but right now it stays on the white costume. Add a “switch costume to” block to the “then” part of the “if/else” block, click on the dropdown menu, and select “black.”

Test the code by clicking the green flag.

The sprite starts out using the white costume.

If it touches black, then the costume switches to black. Great!

But, the costume never switches back to white! The sprite knows to switch to the black costume if it’s touching black, but it doesn’t know what to do otherwise.

That is what the “else” part of “if/else” is for. To make the sprite change to its white costume if it is not touching black, drag another “switch costume to” block inside the else section. Select “white” from the dropdown menu.

Now the code reads “if touching black, switch to costume black, else - or otherwise - switch to costume white” Now, test your code! If the sprite is touching black, it should stamp black. If the sprite is touching anything else, it should stamp white. It should do this all over the screen.

After you’ve finished this step, share your project by clicking the share button at the top of the project editor. Because this project runs best in turbo mode, add instructions to tell people to turn turbo mode on to use your program.

arrow_backward Back
Next arrow_forward
  1. Make the scanner sprite stamp the black color on the stage white, and the white color black.
  2. Use an "if/else" block, and include the "touching color" condition.
  3. Use two "switch costume to" blocks to switch costumes according to the if/else condition.