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.

Moving Your Sprite<br />

Everyone should have a sprite now. The next step is <strong>to</strong> write a script that will make our sprite move on<br />

its own! We write scripts by dragging blocks from the block palate on<strong>to</strong> the scripts area. Since we want<br />

our sprite <strong>to</strong> move, we will use blocks from the motion set (the blue blocks). We’ll first make our sprite<br />

move forward 10 steps, so we’ll drag a block that says move 10 steps on<strong>to</strong> the scripts area.<br />

If you click on the block, you can see the sprite move on the stage.<br />

Click on<br />

block here<br />

Sprite will<br />

move here<br />

If you want the sprite <strong>to</strong> move further, you can make the number of steps bigger. Try making the<br />

number 100 <strong>and</strong> see what happens.<br />

To make the sprite move backwards, you can make the number of steps negative by putting a minus<br />

sign in front of the number. Try making the number of steps -100 <strong>and</strong> see what happens.<br />

The size of the steps that a sprite makes is based on a coordinate system. Every spot on the stage can<br />

be identified by an x, y coordinate. The x coordinates go from left <strong>to</strong> write <strong>and</strong> have values -240 <strong>to</strong> 240.<br />

The y coordinates go from bot<strong>to</strong>m <strong>to</strong> <strong>to</strong>p <strong>and</strong> have values from -180 <strong>to</strong> 180.<br />

mbrace Game Development Workbook Page 6

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

Saved successfully!

Ooh no, something went wrong!