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 – creating a custom shapes procedure


We're going to make procedures (custom blocks) for home and shapes. Home will initialize our drawing environment, and shapes will handle the drawing:

  1. We'll start with defining a home block that sets our initial sprite position and values. From the More Blocks palette, click Make a Block, and name it home as a representation of an initial starting position. It will initialize the our drawing project.

  2. Drag these four blocks from the existing stack, and add them to the defined home block: hide, clear, go to x: (0) y: (0), and point in direction (90).

  3. Then use the home block from the More Blocks palette to replace the four blocks you just removed from the when (d) key pressed script. Check the following screenshot:

  4. Next, we'll make a custom block out of the repeat (sides) block. Create a new custom block named shapes that takes three numbers as inputs: sides, length, and angle. For clarity, you should add a text label to each number input and...