20.03.2013 Views

Introduction to Computer Science with Scratch and App Inventor

Introduction to Computer Science with Scratch and App Inventor

Introduction to Computer Science with Scratch and App Inventor

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Variables <strong>and</strong> Keeping Score<br />

Now that we have the start of a fun game, we want <strong>to</strong> keep score by letting our dinosaur earn a point<br />

for every bowl of cheesy poofs that he eats. In order <strong>to</strong> do this, we are going <strong>to</strong> use VARIABLES.<br />

A program can have many variables, each keeping track of a different value. In order <strong>to</strong> be able <strong>to</strong> tell<br />

our variables apart, we give each variable a name.<br />

Points:<br />

23<br />

To create a variable in <strong>Scratch</strong>,<br />

go <strong>to</strong> the red Variables menu.<br />

Then click on the Make a<br />

variable but<strong>to</strong>n.<br />

This will open a new box where<br />

we can type the name of our<br />

variable. Then click ok.<br />

You can think of a variable like a chalkboard<br />

that can s<strong>to</strong>re one number on it. We can read<br />

the number off the chalkboard or write a new<br />

number on the chalkboard, <strong>and</strong> it will always<br />

keep track of the last thing we wrote down.<br />

You always want <strong>to</strong> give your variable a<br />

descriptive name that explains what<br />

value it represents. Since we want a<br />

variable that will hold the number of<br />

points our dinosaur has, we’ll call our<br />

variable “points”<br />

mbrace Game Development Workbook Page 22

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!