Harry Potter Scratch Game

42
Harry Potter Scratch Game 1 Harry Potter Harry Potter Scratch Game Scratch Game Pranali Choubal Pranali Choubal Kunal Shah Kunal Shah Barb Ericson Barb Ericson [email protected] [email protected] Dec 2007 Dec 2007

description

Harry Potter Scratch Game. Pranali Choubal Kunal Shah Barb Ericson [email protected] Dec 2007. The Game. Use the arrow keys to move Harry Potter to catch the golden snitch to avoid being hit by the bludger. Getting Started. Start Scratch Delete the cat - PowerPoint PPT Presentation

Transcript of Harry Potter Scratch Game

  • Harry Potter Scratch GamePranali ChoubalKunal ShahBarb Ericson [email protected] Dec 2007

    Harry Potter Scratch Game

  • The GameUse the arrow keys to move Harry Potter to catch the golden snitchto avoid being hit by the bludger

    Harry Potter Scratch Game

  • Getting StartedStart ScratchDelete the catClick on scissors and then the cator right click on the cat and pick delete

    Harry Potter Scratch Game

  • Change the BackgroundClick on the stage to select itClick on the Backgrounds tabClick on the import button

    Harry Potter Scratch Game

  • Select New BackgroundNavigate to the HarryPotter folder Select the Stadium and click OK

    Harry Potter Scratch Game

  • The Stage is Set

    Harry Potter Scratch Game

  • Add Harry PotterClick on the folder with a star on it to add a sprite from a fileNavigate to the HarryPotter folderAdd Harry

    Harry Potter Scratch Game

  • The Game so Far

    Harry Potter Scratch Game

  • Scratch is Event DrivenYou can make things happen when events occursuch as a key is pressedthe green flag is clicked ona message is received

    Harry Potter Scratch Game

  • Making Harry MoveClick on the Scripts TabClick on Control and drag out when space key pressedChange to left arrow keyClick on Looks and drag outswitch to costume Change to Harry_LeftClick on Motion and drag outchange x by 1click on 1 and change to -4

    Harry Potter Scratch Game

  • The Scratch StageThe Scratch stage is 480 pixels wide and 360 pixels high.-240240180-180x increases x decreases y increases y decreases

    Harry Potter Scratch Game

  • Add Other Key ScriptsWhen right arrowchange to Harry_Right costumechange x by 4When down arrowchange y by -4When up arrowchange y by 4

    Harry Potter Scratch Game

  • Add the Golden SnitchClick on the folder with a star on it to add a sprite from a fileNavigate to the HarryPotter folderAdd the snitch

    Harry Potter Scratch Game

  • Harry and the Snitch

    Harry Potter Scratch Game

  • Snitch BehaviorIn a 'normal' Quidditch game the game is over when the snitch is caughtBut, in this game you will have to catch 10 snitches to win.you will need to keep track of the number caughtEach time the snitch is caught it will hide and reappear in a new random location

    Harry Potter Scratch Game

  • VariablesTo remember how many snitches were caught we will need a variablethe value stored in a variable can change (vary)Click on the Variables buttonThen click on Make a VariableEnter a name for the variableUse the default of For all spritesClick on OK

    Harry Potter Scratch Game

  • StartingScratch games and animations usually start when you click the green flagClick on Stage to select itClick on Scripts to programClick on Control to see the control blocksDrag the "when green flag clicked" block outClick on Variablesdrag the "set Snitches Caught to 0"

    Harry Potter Scratch Game

  • MessagesScripts can receive messages and broadcast messagesblocks are in the Control areaClick on the snitch sprite, then Scripts then ControlTo create a message drag out the "when I receive" and click on the down arrowthen on newGive the message the name Caughtclick on OK

    Harry Potter Scratch Game

  • More about MessagesBroadcasting and receiving messages is how sprites communicate with each otherit doesn't cause anything to be printed or appearit does execute scripts that receive the messageAll broadcasted messages should have one or more sprites that receive the message

    Harry Potter Scratch Game

  • Responding to CaughtHide the snitchdrag hide from LooksAdd one to the number of snitches caughtdrag from VariablesChange the x and y valuesdrag from motionreplace values with random numbers from NumberShow the snitchdrag from LooksPlay a sounddrag from Sound

    Harry Potter Scratch Game

  • Conditional ExecutionSometimes we want to execute a block or several blocks if some condition is trueuse sensing blocks or number blocks that return true or falsethese have 6 sides (hexagon)The snitch is captured if Harry is touching itUse an if from Control to check if Harry is touching the snitch sprite

    Harry Potter Scratch Game

  • Catching the SnitchIf the Harry Potter sprite is touching the snitch sprite add iffrom Controladd "touching " and change to "Sprite3"from SensingBroadcast the Caught messagefrom ControlRight click on the if block and pick "duplicate" and add to all the other scripts for Harry Potter

    Harry Potter Scratch Game

  • Catching the SnitchRight click on the if block and select duplicateDrop the copy on the other scriptsMove the scripts to see them better

    Harry Potter Scratch Game

  • More on ConditionalsSometimes we want to execute some blocks if a condition is true and other blocks if it is falseUse a if and else block from Control for this

    Harry Potter Scratch Game

  • Winning the GameIn the snitch script that receives the caught messagedrag in a if and else from Controlplace it after the change Snitches Caught by 1move the last 3 tiles into the else partif you have won these don't need to execute

    Harry Potter Scratch Game

  • Winning the Gamedrag in a "blank = blank"from Numberdrag in "Snitches Caught" to the first blank areafrom Variables click on second blank area and type in 10drag in a broadcast blockCreate new message "Won"

    Harry Potter Scratch Game

  • Telling the UserClick on StageClick on BackgroundsClick on ImportNavigate to HarryPotter folderSelect Congratsclick on OK

    Harry Potter Scratch Game

  • Stage ScriptsClick on Stage and ScriptsSet the initial background to the stadium when the green flag is clickedfrom LooksWhen the stage receives a Won messagefrom Controlswitch background to Congratsfrom Looks

    Harry Potter Scratch Game

  • Hide Other SpritesIf the user has wonhide the other spritesHarry PotterSnitchYou can click on the "when I receive Won" and drag it to the snitch sprite to copy itthen click on the snitch sprite and scripts to check the copy worked

    Harry Potter Scratch Game

  • When Game StartsIf the user wins and Harry and the Snitch hide when you restart the gamethey won't show again if you start a new gameAdd "when green flag clicked" show to:Harry Golden Snitch

    Harry Potter Scratch Game

  • Making it Harderadd a Bludgerif the Bludger hits Harry he "dies"start with 3 liveslose a life each time Harry diesif Harry loses all 3 lives you lose the game

    Harry Potter Scratch Game

  • Add Lives VariableClick on VariablesClick on Make a variableEnter LivesDrag display to top right

    Harry Potter Scratch Game

  • Start with 3 LivesClick on StageClick on ScriptsAdd "set Lives to 0" Click on 0 and change to 3

    Harry Potter Scratch Game

  • Painting a BludgerYou can paint a new spriteclick on the paintbrush with a star on itClick the colorClick the circle shape toolClick and drag to make the circleClick on OK

    Harry Potter Scratch Game

  • Loops Sometimes you want to repeat blocks until the game ends or something happensUse a forever block to repeat actions until the game endsuse a stop all block to stop all scripts Use a repeat block to repeat some actions a given number of times

    Harry Potter Scratch Game

  • Bludger ScriptsWhen the green flag is clicked loop foreverset x to 260hide the bludgerwait for some random amount of time between 3 and 5 secondsshow the bludgerGlide to the opposite side x is -260random y from -145 to 145

    Harry Potter Scratch Game

  • Bludger ScriptsWhen the green flag is clicked, loop forevercheck if touching Harryplay a soundreduce the number of livescheck if lostlives = 0wait till not touching Harryor you will die quickly

    Harry Potter Scratch Game

  • Tell User Game OverClick on StageClick on BackgroundsClick on ImportSelect HarryPotter folderSelect Game OverClick OK

    Harry Potter Scratch Game

  • New Stage ScriptClick on ScriptsAdd "when I receive Lost"from ControlAdd "switch background Game Over"from LooksAdd "stop all"from ControlAdd "stop all" to the end of when receive "Won" script too

    Harry Potter Scratch Game

  • Hide Sprites When LoseWhen the game is losthide Harryhide the Snitch

    Harry Potter Scratch Game

  • Project NotesClick on the notepad in the top right cornerType in project notesYou can upload your project to the Scratch web siteClick on Share!See it at http://scratch.mit.edu

    Harry Potter Scratch Game

  • ExtensionsSpeed up the Bludger each time a snitch has been caughtWill need a variable for "Time to Cross"Reduce the variable each time each time the snitch is caughtAdd background musicImport Theme.wavAdd a script to the stageWhen the green flag is clickedLoop forever playing the theme and waiting for it to finishMake the Bludger come from any directionand glide across to the opposite sideAdd Beaters who can hit the Bludger awayUsing the space keyAdd a time limit That counts done

    Harry Potter Scratch Game

    In Scratch you can click on numbers and type in new numbers. When you drag blocks out a white line will appear to show you where the block will go when you drop it. X increases to the right and decreases to the left. Y increases going up and decreases going down.Try it and see Harry fly around the stadium when you press the arrow keys.Names for variables in Scratch can have spaces in them. Be sure that you drop the set Snitches Caught to 0 block when the white line shows that it will be connected to the when green flag clicked block. You can check this by clicking and dragging on the when green flag clicked and check that both blocks move.When the snitch is caught it should hide and then add 1 to the number of snitches caught variable. Then it should go to a random location on the screen (avoiding the top of the screen since the variables are shown there). Then show the snitch and play a sound.If you run out of room scroll bars will appear. Use these to see the rest of the scripts.If the user has won the game there is no need to move the snitch and show it and play a sound.We will tell the user s/he won by changing the background on the stage. This is like dropping a curtain on a real stage. It changes the backgroundof the stage but the actors are still on the stage.We call items that allow you to repeat blocks a loop or iteration.A forever loop will stop when the stop all scripts.If you don't wait till you aren't touching Harry this loop will repeat and you will end the game very quickly.The stop all will stop other scripts even if they have a forever loop.