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 – breaking out of the circle


Not all of our art needs to create a circle, and just to prove it, the following is a quick example:

  1. For this pattern, we'll use a variable called counter as both a way to control the number of times to repeat the pattern and a multiplier for the ever-changing x and y coordinates. Create the variable, if you don't have one in your current project.

  2. Set the initial values for the pattern as shown in the following set of blocks:

    • set (counter) to (0)

    • clear

    • hide

    • set pen size to (1)

  3. Add a repeat () until block and use the condition (counter) > (25) as the value. Repeat the following set of blocks:

    • pen up

    • go to x: ((counter) * (10) y: (0)

    • pen down

    • go to x: (0) y: (250) – ((counter) * (10))

    • change (counter) by (1)

  4. The resulting pattern should match the following screenshot:

What just happened?

The key to this pattern is the use of the counter variable as a multiplier. The pattern starts at (0, 0) and moves right along the x axis in increments...