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 Alternating Patterns (Challenge)


Hey, my name is KaMar and I am going to tell you about the “Draw an Alternating Pattern” add-on. In this add-on, you will draw and program two shapes to create an alternating pattern. To start, draw two new costumes for the pattern maker sprite. This example will demonstrate how to use the line, ellipse, and fill tools to make patterns, but you can draw your pattern however you’d like.

Select the pattern maker sprite and the costumes tab. Click paint new costume.

To create the first pattern, select the line tool and a color. Then, draw a series of overlapping lines. Use the fill tool to color this pattern. If you do something that you don’t like, click the undo tool. Once you’ve finished this pattern, center it using the “set costume center” button. Then, rename the costume. This example names it “line pattern.”

Click the “paint new costume” button to create the second pattern using the ellipse and fill tools. Similar to the line pattern, draw a series of ellipses, and use the fill tool to color them. The two patterns that you draw will be used together, so select colors for the ellipses that work well with the line pattern. Center this pattern using the “set costume center” button. Then, rename the costume. This example names it “circle pattern.” Next, program these new costumes to alternate to create a new pattern. Click the scripts tab. Duplicate a “key pressed” event block stack, and select a new key to start this code. This example will use “space.” This block stack is currently programmed to draw one shape. Select one of your new patterns in the “switch costume” block, click the flag, then press the selected key to run it. Great. To see how the second pattern looks, select the other costume in the “switch costume” block, and run it.

To alternate between costumes, switch costumes in the “repeat until” block.

Drag the “switch costume” block into the loop. When this code runs, the costume switches to the circle, the print prepare block creates the spacing and size for the pattern, then the sprite stamps. Click the flag, and press the selected key to try it. Great, it still works. Right click the "switch costume" block to duplicate this code stack, and place the new stack in the repeat until loop. Select the other pattern in the “switch costume” block. Click the flag to test and press a key. Whoa!

Both patterns show. Tinker with the values in the “print prepare” block to see different spacing and sizing looks. To find out what a value does, look at the define block. For example, the first value in the block controls the horizontal spacing.

Once you’ve programmed an alternating pattern, experiment with drawing different shapes, patterns, and colors to create new costumes. You can even try to use the vector editor to make alternating shapes that look like camouflage.

Now, it’s your turn: Draw two new costumes for the pattern maker sprite. Duplicate a “when key pressed” block stack, and change the value to a different key press. Add the “switch costume” block to the repeat loop, and duplicate the inner block stack.

Change the costume values to the two new patterns. Tinker with the values in the “print prepare” block to see how different sizing and spacing affects the pattern’s look.

Choose an Add-On
Welcome to My Project
Program a sprite to introduce your project.
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.
New Fabrics
Add more fabrics to your pattern maker.
Title Sprite
Add a title slide to your project.
arrow_backward Back
Next arrow_forward
  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!