Skip to content

Please update your browser

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

Transcript

In this add-on, enable the user to pick the color of the pattern.

Note that this add on works best when sprites are a single color.

To being, click the pattern maker sprite then the costumes menu.

You need costumes that are distinctly different colors.

An easy way to create different color costumes is to duplicate a costume and fill it with different colors.

To accomplish this, right click a costume then click duplicate.

Click the duplicated costume, select a different color you like.

Now, click the parts of the image you want to fill with the new color.

You can repeat this process a couple times.

It's tempting to create costumes that are every color of the rainbow, but for now, limit yourself to four different costumes.

You can always go back and add more costumes later.

But right now, you want to leave enough time to finish coding your project.

Rename each of the costumes to reflect their colors.

In this example, the costumes are named Blue, Red, Yellow, and Black.

Next, add a sprite that will ask the user what color the pattern should be.

Click that add a sprite from library icon and select a sprite.

Next, add an ask block from the sensing menu.

In the field, ask what color the user wants the sprite to be and specify which colors are available.

To change the sprites costume based on the user's answer, create a conditional statement.

Under the ask block, add an if then block.

Then, place an equals block from the operator menu in the if portion of the if then block.

Next, add an answer block to one side of the equals block.

On the other side, enter the color of one of the costumes.

Next, place a broadcast block in the then portion of the if then block.

From the dropdown menu of the broadcast block, select new message, and call the message the same name as the color.

In this example the code says, "If the users "message equals red, then broadcast the message red".

Now switch to the pattern maker sprite.

This step is really important because the sprite is the one you'll need to program next.

Drag out the when I received block and select the message you just created from the drop-down menu.

Duplicate the code below the when one key press block and add it to the bottom of this code stack.

In the switch costume block choose the correct color costume from the drop down menu.

Now, the user is able to choose one color.

Repeat this process is each color, so that they can pick the other colors you created.

Each time you broadcast a message for a color, make sure the correct color costume is selected.

Finally, select the sprite that will ask the user which color pattern they want to see.

Add an event that triggers the sprite to ask this question.

In this example, the sprite asks the questions when the flag is clicked, but you can use another event like when the sprite clicked, or when the space key pressed.

Add detailed instructions about how to make your project work to the project page.

Now it's your turn.

Duplicate the pattern maker costume.

Fill the new costume with a different color.

Repeat this process a couple more times if you'd like.

Add a sprite.

Create a conditional statement that uses the ask block and the answer block to change the color of the patter to the user's answer.

Broadcast a message to the pattern sprite to change it's costume when it receives the message.

Finally, duplicate the code below the when one key press block and add to the bottom of this code stack.

Choose an Add-On
Color Selector
Enable the user to pick the color of the pattern.
Alternating Patterns (Challenge)
Create a unique alternating pattern.
Soundtrack (Challenge)
Add background music to your project.
Title Sprite
Add a title slide to your project.
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!
Attributions
  • "Pattern Maker Starter Project remix" by csf18489 (https://scratch.mit.edu/projects/54172540/) -- Licensed by CC BY-SA 2.0 (https://creativecommons.org/licenses/by-sa/2.0/)
  • "Pattern Maker Starter Project remix" by csf47269 (https://scratch.mit.edu/projects/54172540/) -- Licensed by CC BY-SA 2.0 (https://creativecommons.org/licenses/by-sa/2.0/)
  • "Fabric generator" by csf11191 (https://scratch.mit.edu/projects/46083714/) -- Licensed by CC BY-SA 2.0 (https://creativecommons.org/licenses/by-sa/2.0/)
  • "Pattern Maker Starter Project remix-2" by kpolk50349 (https://scratch.mit.edu/projects/54172540/) -- Licensed by CC BY-SA 2.0 (https://creativecommons.org/licenses/by-sa/2.0/)