Book Image

Scratch Cookbook

By : Brandon Milonovich
Book Image

Scratch Cookbook

By: Brandon Milonovich

Overview of this book

Scratch 2.0 is an easy to use programming language that allows you to animate stories and create interactive games. Scratch also gives you the capability of using programming to calculate complicated calculations for you. Scratch Cookbook will lead you through easy-to-follow recipes that give you everything you need to become a more advanced programmer. Scratch Cookbook will take you through the essential features of Scratch. You'll then work through simple recipes to gain an understanding of the more advanced features of Scratch. You will learn how to create animations using Scratch. Sensory board integration (getting input from the outside environment) will also be covered, along with using Scratch to solve complicated and tedious calculations for you. You'll also learn how to work through the exciting process of project remixing where you build on the work of others. Scratch Cookbook will give you everything you need to get started with building your own programs in Scratch that involve sounds, animations, and user interaction.
Table of Contents (17 chapters)
Scratch Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Drawing with the pen


Pens are a category of blocks we can use to draw on the stage. This recipe will explore using the pen to draw a square on the stage.

This is a new category we haven't used before in the block palette:

Getting ready

All you need to do to get this recipe started is open a new Scratch file. We'll be using the default sprite. It may also be fun to add the grid background to the stage.

How to do it...

Follow these steps to draw a square on the stage:

  1. Drag a green-flag block in to the script area.

  2. Drag a clear block from the Pen category.

  3. From the Motion category, drag a go to x: () y: () block. Set both values to 0.

  4. Drag a point in direction () block in to the sequence. Change the value to 0. You'll now have the following:

  5. Drag a move () steps block. Change the value to 100.

  6. Drag a point in direction () block and change the value to 90.

  7. Next, place a set pen color to () block from the Pen blocks. Click on the color to select a color you like.

  8. Drag a set pen size to () block from the...