m m m
ming with Scratch m m
Ronald Bourret http://www.rpbou
m m
rret.com/scratch
Table of Contents
m m
Introduction ................................................................................................................................. 3
Chapterm1:mMovementmandmLoops ............................................................................................... 5
Chapterm2:mConditionalmActionsmandmKeyboardmCommands ...................................................... 9
Chapterm3:mMessages ................................................................................................................. 13
Chapterm4:mAnimation ............................................................................................................... 15
Chapterm5:mPractice,mpractice,mpractice! .................................................................................... 21
Chapterm6:mVariables ................................................................................................................. 23
Chapterm7:mAlgorithms .............................................................................................................. 29
Chapterm8:mProgrammStructure ................................................................................................... 33
Chapterm9:mAdvancedmPrograms ................................................................................................ 41
Chapterm10:mProject ................................................................................................................... 43
,Scratch
ThismclassmintroducesmprogrammingmusingmthemScratchmprogrammingmlanguage.mThemScratchmprogrammingmlang
uagemandmenvironmentmaremamprojectmofmthemLifelongmKindergartenmGroupmatmthemMITmMediamLab.
Theymaremavailablemfreemofmcharge.mY
oumcanmfindmScratchmat:
http://scratch.mit.edu
License
ThismdocumentmismavailablemundermthemCreativemCommonsmAttribution-NonCommercial-
ShareAlikem4.0mInternationalm(CCmBY-NC-SAm4.0)mlicense.mUndermthismlicense,myoummay:
• Sharem—mcopymandmredistributemthemmaterialminmanymmediummormformat
• Adaptm—
remix,mtransform,mandmbuildmuponmthemmaterialmUndermthemfoll
m
owingmterms:
• Attributionm—
mYoummustmgivemappropriatemcredit,mprovidemamlinkmtomthemlicense,mandmindicatemifmchangesmwere
mmade.mYoummaymdomsominmanymreasonablemmanner,mbutmnotminmanymwaymthatmsuggestsmthemlicens
ormendorsesmyoumormyourmuse.
• NonCommercialm—mYoummaymnotmusemthemmaterialmformcommercialmpurposes.
• ShareAlikem—
mIfm youmremix,mtransform,mormbuildmuponmthemmaterial,m yoummustmdistributemyourmcontributio
nsmundermthemsamemlicensemasmthemoriginal.
Formamhuman-
readablemsummarymofmthismlicense,msee:mhttp://crea
tivecommons.org/licenses/by-nc-sa/4.0/
Formthemcompletemlicense,msee:mhttp://creativecommons.org/licenses
/by-nc-sa/4.0/legalcode
2
,Introduction
ThismtutorialmwillmintroducemyoumtomprogrammingmusingmScratchmfrommMIT.
Create a Scratch Account
m m m
Beforemyoumstartmprogramming,myoumwillmneedmtomcreatemamScratchmaccount.
1. Gomtomscratch.mit.edu.
2. ClickmJoinmScratch.
3. Entermthemrequestedminformation.m(Usemyourmrealmbirthmmonthmandmyear.mDomnotmusemyourmschoolme
mailmaddress,masmitmcannotmreceivememailmfrommScratch.)
Scratch Editor
m
ThemScratchmeditormhasmthreemmainmparts:
• Stage:mWheremyourmprogrammruns.
• Spritemlist:mAmlistmofmthemspritesm(objects)minm yourmprogram.
• Scriptmeditorm/mcostumemeditor:mWheremyoumeditmyourmprogramsmormyourmsprite’smpictur
es.mWhenmthemScriptsmtabmismchosen,mthemscriptmeditormismshownm(outlinedminmred):
Themscriptmeditormhasmthreemmainmparts:
• Scriptmarea:mWheremyoumbuildmscripts.
• Blockmmenu:mWheremyoumchoosemthemcategorymofmblocksm(programmingmstatements)mtomuse.
• Blockmpalette:mWheremyoumchoosemthemblockmtomuse.
3
, WhenmthemCostumesmtabmismchosen,mthemcostumemeditormismshownm(outlinedminmred):
4