3Game DescriptionWe will make a game where the player controls a witch using the arrow keys to catch a falling pumpkin. If the witch misses the pumpkin the game is over.
4Start up Scratch Click on Scratch.exe This set of slides assumes that you have already explained how to connect tiles together (when you see the white line). And have explained that the center of the window is 0,0.
5Delete the CatClick on the scissors and your cursor turns to scissors and then click on the cat to delete itOr right click on the cat and pick delete
6Add the WitchClick on the button with the picture of folder with a star in itif you hover over it, it says "Choose new sprite from file"
8Scroll to the WitchClick on the witch and then OK
9Resize Your Sprite!You can make your sprite larger or smaller by using the “grow sprite” or “shrink sprite” icons.You click on one of these icons, then click on your sprite until it is the size you’d like.shrinkgrow
10Move the SpriteSelect (click on the arrow and then on the sprite) and click and drag the sprite to the bottom of the window
11Add a BackgroundClick on the Stage in the area that shows the sprites and stageClick on the Backgrounds tabClick on the import buttonPick a backgroundLike night-city in outdoors
12Event Handling We want to control the witch using the arrow keys When we click the left arrow the witch should move leftWhen we click the right arrow the witch should move rightThis is a form of event handlingResponding to user actions like mouse clicks and key presses
13The Scratch StageThe Scratch stage is 480 pixels wide and 360 pixels high.180Moving left decreases the x valueMoving right increases the x value-2400,0240at the center of the stage-18013
14Programming the WitchClick on the witch sprite in the view of the sprites and stageBottom right sectionClick on the Scripts tabIn the center areaThis allows us to create scripts (programs) for the witch
15Respond to Arrow KeysClick on Control (orange) and then drag out "when space key pressed"
16Respond to Right ArrowClick on down arrow next to space and select right arrowClick on Motion (blue) and drag out "move 10 steps"
17Change the move amount Click on the 10 Type 5 and press enter it will highlight in blueType 5 and press enter
18Respond to Arrow Keys Click on Control (orange) Drag out "when space key pressed"Change "space" to "left arrow"Click on MotionDrag out "move 10 steps"Change it to -5 (to move left)Click on the stage and try out the left and right arrow keysDoes the sprite leave the window?You can also use the stamp (top right) to make a copy of the first two blocks and then modify them to be left arrow and -5.
19Paint a Pumpkin Click on the paint brush and star It will say "Paint new sprite" if you hover over it
20Draw the Pumpkin Click the circle tool Circle and eyedroppper toolsClick the circle tooland then use the eyedropper to pick an orange colorand then click in the drawing area and drag to create the pumpkinClick the line toolAnd then use the eyedropper to pick blackAnd then click in the drawing area and drag to create a lineDrawing areaClick ok when done
21Size the pumpkin as desired and move it to the top Click and drag the pumpkin to the top of the window
22Make the Pumpkin FallWhen the green flag is clicked we want the pumpkin to always start at the top and fall downClick on Control (orange)Drag out "When green flag clicked"Be sure that the current sprite is the pumpkin.
23Start the Pumpkin Click on Motion (blue) Drag out “go to x # y # “ this will always start the pumpkin at its current position (Scratch doesn’t automatically put it back for you).
24Sequential Execution One block is executed after the other In order from top to bottomWhen the green flag is clickedthe pumpkin will go to the specified x and y location
25LoopsWe want the pumpkin to continue to move down unless the witch catches itHow do we make this happen?We could use lots of blocks one after the otherBut, that would be slow and repetitiveWe need a way to repeat a block or set of blocksThis is called a loop or iterationIn scratch we can use a forever loopExecutes the blocks inside of it until the script is stopped
26Make the pumpkin fall Click on Control (orange) Click on Motion (blue) drag out "forever"Click on Motion (blue)drag out “change y by 10”Change it to -1Try it out!The forever block will make anything inside it repeat until you stop the script or all scripts.
27Catch the pumpkin! If the pumpkin touches the witch then it is caught Let's track how many pumpkins we have caught with a scoreWe will increment the score each time we catch a pumpkin
28Variables If we are going to keep track of the score We want something to hold the current scoreAnd we want to be able to change the scoreWe want the value to change or varyThis is called a variable
29Track the score When we start the game set the score to 0 Click on Variables (red)Click on Make a VariableName it score
30Set score to 0 Highlight the pumpkin sprite Drag the “forever” down Drag out "set score to 0“Drag the “forever” back upNotice the score showing on the window
31ConditionalsWe want to increase the score if the witch caught the pumpkinSo this action will only occur only if some condition is trueThis is called a conditional or an “if”
32Did we catch the pumpkin? From Control drag out an “if”Check if the pumpkin is touching the witchGet this in SensingIf this is true increment the scoreFrom VariablesNotice that the blank < blank green block is a hexagon and you can only put hexagons in the blank part of the if block.
33Increment the score Try it out! Computers do what you tell them to do is this what you expected?Computers do what you tell them to doNow what you want them to doThe score increases each time the ball moves and is still touching the sprite. We really want the ball to move back to the top of the window instead once we catch it.
34Reset the Pumpkin If we caught the pumpkin Increment the score And move the pumpkin to some random spot at the top of the window
35Reset the Pumpkin Click on Number drag out "pick random 1 to 10" drop on the x value after “go to x:”change the 1 to -235 and change 10 to 235change the y value to match the y in the first “go to x # y #”
36Adding LosingIf the witch doesn't catch the pumpkin it just gets stuck at the bottom of the screenLet's tell the player that he or she lost
37Add text sprite Click on the Paint new sprite button Click on the T for textPick the red colorModify the font sizeMove the square to where you want the textType You Lost!
38Hide the spriteWe don’t want to tell the player that she lost when the game startsSo hide the message when the game startsClick on Controldrag out "when green flag clicked"Click on Looksdrag out “hide”Be sure that this script is on the text sprite.
39Check if Lost If the y position gets near the bottom (near -180) Drag out an iffrom ControlDrag out a blank < blankFrom NumbersAdd a y positionFrom Motion
40Broadcast a message Sprites communicate by passing messages One sprite broadcasts the messageOther sprites can listen for it and react to it when they receive itClick on Controldrag out "broadcast blank"click on the drop down arrownext to new – name it lostAdd “stop script”to stop the forever loopSprites communicate by passing messagesOne sprite broadcasts the messageOther sprites can listen for it and react to it when they receive itClick on Controldrag out "broadcast blank"click on the drop down arrownext to new – name it lostAdd “stop script”to stop the forever loop
41Receive Lost Click on the text sprite Click on Control Click on Looks drag out "when I receive blank"click on the down arrow and select lostClick on Looksdrag out “show”drag out “stop all”to stop all scriptsThe stop all will stop all the scripts from executing.
42Parallel ExecutionWe have several things happening at the same time when the green flag is clickedThis is called parallel execution
43Create InstructionsClick on the Show Project Notes in the upper right cornerAdd the author and instructionsPress OK
44Test your game Click the green flag If you want, adjust the speed of the pumpkinIncrease the amount it changes in yModify the sprites using the “Costume” tabSave your game with the “Save” button
45Share your game You can share your projects at the scratch web site Click on the Share! buttonYou can also download other projects and see how they were created
46Other Ideas Add a sound when you lose Add the ability to win When you reach a certain scoreTrack the amount of time it takes as wellSpeed up the pumpkin over timeAdd more sprites to catchAdd a sprite to avoid (like a ghost)killer sprite
47Concept Summary Variables Forever loops Conditionals – ifs can hold values and can change valueForever loopsrepeat all the commands inside of them one at a time until the script is stopped or all scripts are stoppedConditionals – ifsonly execute the body of the if when the condition is trueSprites can pass messagesand receive themSprites can react to eventslike clicking the green flag and pressing the left or right arrow keysSprites can have several scripts, costumes, and soundsThings can happen one after the other – sequential execution or at the same time – parallel execution