Note that this add-on works best when sprites are a single color.
To begin, click the pattern maker sprite, then the costumes menu.
An easy way to create different-colored costumes isto 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 differentcolor you like, then click the "color a shape" icon. Now, click the parts of the image youwant to fill with a new color.
You can repeat this process a couple of times. It's tempting to create costumes that areevery color of the rainbow, but for now limit yourself to four different costumes. You canalways go back and add more costumes later, but right now you want to leave enough timeto finish coding your project.
Rename each of the costumes to reflect their colors. In this example, the costumes arenamed blue, red, yellow, and black.
Next, add a sprite that will ask the user what color the pattern should be. If you completedthe Pattern Project Introduction add-on, you might have already added a sprite that couldask this question. If not, click the "add sprite from library" icon, and select a sprite.
Next, add an "ask" block from the sensing menu. In the field, ask what color the userwants the sprite to be and specify which colors are available.
To change the sprite's 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 fromthe 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 ofthe costumes.
Next, place a "broadcast" block in the "then" portion of the "if-then" block. From the dropdownmenu of the “broadcast” block, select "new message," and call the message the samename as the color.
In this example, the code says: If the user's answer equals red, then broadcast the message “red.”
Now, switch to the "pattern maker" sprite. This step is really important because thissprite is the one you will program next.
Drag out the "when I receive" block, and select the message youjust created from the dropdown menu.
Duplicate the code below the "when 1 key pressed" block,and add it to the bottom of this code stack.
In the switch costume block, choose the correct color costume from the dropdown menu.
Now, the user is able to choose one color.
Each time you broadcast a message for a color,make sure the correct color costume is selected. Finally, select the sprite that will ask theuser which color pattern they want to see. Add an event that triggers the sprite to askthis question. In this example, the sprite asks the question when the green flag is clicked.
But, you can use another event, like “when this sprite clicked” or “when space key pressed.”