Skip to content

Please update your browser

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

arrow_back Color Filter

Transcript

In this video you will use functions to make the scanner sprite make different stamping patterns.

To do this you will duplicate parts of your code, and use the "make your own block" ability.

Scratch allows you to define your own blocks and make your own functions.

This is a neat way to clean up your code, and organize different functionalities in your program.

In the shadow maker project the stamping if else statement can be made into its own block or function, that will make it simpler to understand and play with.

To do this, click on the more blocks tab, And select make a block.

Type in Black and white to describe what your project currently does.

Define what the block will do.

Remove the if else statement from your regular stack, and place it under the define block.

Then pull out the Black and white block, and place it where the if else statement used to be.

Test your project.

It should work exactly like it did before.

All that you have done is renamed the if else statement, Black and white.

Make the background different colors by adding a new function block.

This example uses red but you can use any color.

Make another new block and name it Red and white.

The definition of this new block will almost exactly match the first block you created.

So duplicate the stack underneath the Black and white stack.

Move the new if else statement to underneath Red and white.

To make the scanner sprite stamp red create a new costume.

This needs to be pretty exact to work properly.

Go to the costumes tab and duplicate the black costume.

Now zoom into the editor, and change the color of the little square to red.

Using the paint bucket.

Rename the costume to Red.

Return to the scripts tab.

In the new red and white function you created, change the drop down box of this changed costume block to red.

This makes the scanner sprite stamp red.

Test it by replacing the black and white block, with the red and white block.

Awesome.

Make the scanner sprite change colors as it runs, by adding another if statement after the if else statement, in the function block and before the stamp block.

Add the Sensing block key space pressed to the if then statement.

Add the first block you created, Black and white, and place it in the then spot.

Whenever the program is run, press the space key to make the scanner sprite switch colors when it stamps.

Once you've finished this add on, go to your project page to update your project instructions so people know they can space key to change colors.

You can return to your project by clicking the See Inside button.

Now it's your turn.

Create a new function by using the "make your own block" feature and an if else conditional statement.

Create another function by duplicating the if else function.

Add a new costume, and change the color of the scanner sprite.

And finally, add more if statements, to allow you to change the color of the scanner sprite while the program runs.

Choose an Add-On
Digital Shift
Apply the filter to other backgrounds!
Print Negative
Make complete shadows of new sprites.
Color Filter
Create a variety of color-changing effects.
Draw your Own
Apply the filter to a drawing you create!
arrow_backward Back
Next arrow_forward
Instructions
  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!