Boat Race

Scratch
1
BoatRace
AllCodeClubsmustberegistered.Registeredclubsappearonthemapat
codeclub.org.uk-ifyourclubisnotonthemapthenvisitjumpto.cc/18CpLPytofind
outwhattodo.
Introduction
Youaregoingtolearnhowtomakeagame,inwhichyou’llusethemouse
tonavigateaboattoadesertisland.
ActivityChecklist
FollowtheseINSTRUCTIONSonebyone
TestyourProject
ClickonthegreenflagtoTESTyourcode
SaveyourProject
MakesuretoSAVEyourworknow
1
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
Step1:Planningyourgame
ActivityChecklist
1. StartanewScratchproject,anddeletethecatspritesothat
yourprojectisempty.YoucanfindtheonlineScratcheditor
atjumpto.cc/scratch-new.
2. Clickonyourstagebackdropandplanoutyourlevel.You
shouldadd:
Woodthatyourboathastoavoid;
Adesertislandthatyourboathastogetto.
Here’showyourgamecouldlook:
Step2:Controllingtheboat
ActivityChecklist
1. Ifyourclubleaderhasgivenyoua‘Resources’folder,click
2
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
‘Uploadspritefromfile’andaddthe‘boat.png’image.You
shouldshrinkthespriteandputitinit’sstartingposition.
Ifyoudon’thavetheboat.pngimage,youcandrawyourown
boatinstead!
2. Youaregoingtocontroltheboatwithyourmouse.Addthis
codetoyourboat:
3. Testoutyourboat,byclickingtheflagandmovingthemouse.
Doestheboatsailtowardsthemouse?
4. Whathappensiftheboatreachesthemousepointer?
Tostopthishappening,you’llneedtoaddan if blocktoyour
code,sothattheboatonlymovesifitismorethan5pixels
3
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
awayfromthemouse.
5. Testoutyourboatagain,tocheckwhethertheproblemhas
beenfixed.
Saveyourproject
4
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
Step3:Crashing!
Yourboatcansailthroughthewoodenbarriers!Let’sfixthat.
ActivityChecklist
1. You’llneed2costumesforyourboat,onenormalcostume,and
oneforwhentheboatcrashes.Duplicateyourboatcostume,
andnamethem‘normal’and‘hit’.
2. Clickonyour‘hit’costume,andchoosethe‘Select’tooltograb
bitsoftheboatandmoveandrotatethemaround.Makeyour
boatlookasifit’scrashed.
3. Addthiscodetoyourboat,insidethe forever loop,sothatit
crasheswhenittouchesanybrownwoodenbits:
5
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
Thiscodeisinsidethe forever loop,sothatyourcodekeeps
checkingiftheboathascrashed.
4. Youshouldalsomakesurethatyourboatalwaysstartslooking
likeit’s‘normal’.
5. Nowifyoutrytosailthroughawoodenbarrier,youshouldsee
thatyourboatcrashesandmovesbacktothestart.
Saveyourproject
Challenge:Winning!
Canyouaddanother if statementtoyourboat’scode,so
thattheplayerwinswhentheygettothedesertisland?
Whentheboatgetstotheyellowdesertisland,itshouldsay
‘YEAH!’andthenthegameshouldstop.You’llneedtousethis
code:
6
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
Saveyourproject
Challenge:Soundeffects
Canyouaddsoundeffectstoyourgame,forwhentheboat
crashes,orreachestheislandattheend.Youcouldevenadd
backgroundmusic(seetheprevious‘RockBand’projectifyou
needhelpwiththis).
Saveyourproject
Step4:TimeTrial
Let’saddatimertoyourgame,sothattheplayerhastogettothedesert
islandasfastaspossible.
ActivityChecklist
1. Addanewvariablecalled time toyourstage.Youcanalso
changethedisplayofyournewvariable.Ifyouneedhelp,have
alookatthe‘Balloons’project.
7
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
2. Addthiscodetoyourstage,sothatthetimercountsupuntil
theboatreachesthedesertisland:
3. That’sit!Testoutyourgameandseehowquicklyyoucanget
tothedesertisland!
Saveyourproject
8
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
Step5:Obstaclesandpower-ups
Thisgameisfartooeasy-let’saddthingstomakeitmoreinteresting.
ActivityChecklist
1. Firstlet’saddsome‘boosts’toyourgame,whichwillspeedup
theboat.Edityourstagebackdropandaddinsomewhite
boosterarrows.
2. Youcannowaddsomecodetoyourboat’s forever loop,so
thatitmoves2extrastepswhentouchingawhitebooster.
3. Youcanalsoaddinaspinninggate,whichyourboathasto
avoid.Addinanewspritecalled‘gate’,whichlookslikethis:
9
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
Makesurethatthecolourofthegateisthesameasthe
otherwoodenbarriers.
4. Setthecenterofthegatesprite.
5. Addcodetoyourgate,tomakeitspinslowly forever .
6. Testoutyourgame.Youshouldnowhaveaspinninggatethat
youmustavoid.
10
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
Saveyourproject
11
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
Challenge:Moreobstacles!
Canyouaddmoreobstaclestoyourgame?Herearesome
ideas:
Youcouldaddgreenslimetoyourbackdrop,whichslows
theplayerdownwhentheytouchit.Youcanusea wait
blocktodothis:
Youcouldaddamovingobject,likealogorashark!
Theseblocksmayhelpyou:
Ifyournewobjectisn’tbrown,you’llneedtoaddtoyourboat
code:
Saveyourproject
12
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
Challenge:Moreboats!
Canyouturnyourgameintoaracebetween2players?
Duplicatetheboat,renameit‘Player2’andchangeits
colour.
ChangePlayer2’sstartingposition,bychangingthiscode:
Deletethecodethatusesthemousetocontroltheboat:
…andreplaceitwithcodetocontroltheboatusingthearrow
keys.
Thisisthecodeyou’llneedtomovetheboatforward:
You’llalsoneedcodeto turn theboatwhentheleftandright
arrowkeysarepressed.
13
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!
Saveyourproject
Challenge:Morelevels!
Canyoucreateadditionalbackdrops,andallowtheplayerto
choosebetweenlevels?
Saveyourproject
14
TheseprojectsareforuseinCodeClubswithintheUK.ForclubsoutsidetheUK,pleasevisitprojects.codeclubworld.org.Ourcurriculumisdevelopedintheopenon
GitHub(github.com/CodeClub),andweencouragecontributionsfromourcommunity-comeandjoinus!