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

Object interaction with a background


We are going to want to make something separate happen when the balls touch the left boundary of the stage. This may mean a loss in points; however, for the time being we'll just make it end the game.

Getting ready

We'll first turn our attention to the stage. More specifically, we need to adjust our white background. Our goal is to find a way to differentiate the left boundary of the stage from the rest of the stage.

Get this started by going to the Backdrops tab of the stage script area. There we see our default white background. We'll also see the Paint Editor.

You will notice the rectangle tool on the side. Click on that and make a thin line moving from the top of the stage to the bottom on the left. Refer to the following screenshot for a guideline. Make sure you make the line thick enough so that it will be detected with the blocks we are about to add:

We're ready to go!

How to do it...

Return to the script area for either ball and perform the following...