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.

User Controlled Sprites <strong>and</strong> Branching<br />

When you click the import but<strong>to</strong>n, a box will<br />

open that lets you navigate through the<br />

library of backgrounds.<br />

Pick one that you like <strong>and</strong> click OK <strong>to</strong> make it<br />

the new background on your stage.<br />

To go back <strong>to</strong> working on your script for your<br />

sprite, you just click on the sprite in the sprite<br />

list.<br />

Click here <strong>to</strong> go<br />

back <strong>to</strong> your<br />

sprite<br />

For both sprites <strong>and</strong> backgrounds, you aren’t limited <strong>to</strong> the options in the <strong>Scratch</strong> library. You can also draw<br />

your own sprites, modify existing sprites, or import drawing/pho<strong>to</strong> files from your computer. We will see<br />

how <strong>to</strong> do this in later lessons.<br />

Up until now, all of our sprite’s actions have been controlled by move blocks. However, in a game, we’ll<br />

want the user <strong>to</strong> be able <strong>to</strong> move the sprite around using the keyboard. In order <strong>to</strong> be able <strong>to</strong> do this,<br />

we need <strong>to</strong> learn a new control block first:<br />

The if block implements a BRANCHING control structure.<br />

Branching lets us choose <strong>to</strong> do something, only if certain<br />

conditions are met. We do this all of the time in real life.<br />

For example, we might say if it is raining, take an umbrella<br />

outside. This means that when the condition “it is raining”<br />

is true, we should take an umbrella outside <strong>with</strong> us. We<br />

will use branching in programming in much the same way.<br />

mbrace Game Development Workbook Page 12

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

Saved successfully!

Ooh no, something went wrong!