Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By : Michael Badger
Book Image

Scratch 2.0 Beginner's Guide: Second Edition

By: Michael Badger

Overview of this book

Table of Contents (18 chapters)
Scratch 2.0 Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – turning triangles into pinwheels


We're just a few blocks short of turning our basic shapes into art and patterns. Let's perform the following steps to do so:

  1. Create another variable called revs (short for revolutions). We'll use this as the number of times to repeat our shape. Turn the stage monitor into a slider.

  2. Enclose the repeat (sides) block with a new repeat () block. Add the revs variable as the value in this new block.

  3. Add a turn () degrees block after the inner repeat (sides) block. Use the calculation 360 divided by revs for the turn value. The final script looks like the following screenshot:

  4. Now things are getting interesting. Set the values for the sides, length, revs variables as 3, 100, and 3, respectively. Then redraw the shape by changing revs to 6, 12, and 24, respectively. The following screenshot shows the pattern:

What just happened?

The revs variable allows the users to determine how many times to repeat the pattern, but the most important block to drawing...