Make a Simple Game in Scratch Mike Scott University of Texas at Austin Many Thanks to Barb Ericson of Georgia Tech
Slide 2Goals Learn about occasion taking care of basic consecutive execution circles factors conditionals parallel execution message passing
Slide 3Game Description We will make a diversion where the player controls an infant utilizing the bolt keys to get a falling ball. In the event that the infant misses the ball the amusement is over.
Slide 4Start up Scratch Click on Scratch.exe
Slide 5Delete the Cat Click on the scissors and your cursor swings to scissors and after that tap on the feline to erase it Or right tap on the feline and pick erase
Slide 6Add the Baby Click on the catch with the photo of organizer with a star in it in the event that you drift over it, it says "Choose new sprite from file"
Slide 7Select the People Folder
Slide 8Scroll to the Baby Click on the infant and afterward OK
Slide 9Resize Your Sprite! You can make your sprite bigger or littler by utilizing the "develop sprite" or "therapist sprite" symbols. You tap on one of these symbols, then tap on your sprite until it is the size you'd like. contract develop
Slide 10Move the Sprite Select (tap on the bolt and after that on the sprite) and snap and drag the sprite to the base of the window
Slide 11Add a Background Click on the Stage In the base right territory Click on the Backgrounds tab In the inside Click on the import catch Pick a foundation Like bedroom1 in inside
Slide 12Event Handling We need to control the infant utilizing the bolt keys When we tap the left bolt the child ought to move left When we tap the right bolt the infant ought to move right This is a type of occasion taking care of Responding to client activities like mouse snaps and key presses
Slide 13The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high. 180 Moving left reductions the x esteem Moving right builds the x esteem - 240 0,0 at the focal point of the stage - 180
Slide 14Programming the Baby Click on the infant sprite in the perspective of the sprites and stage Bottom right segment Click on the Scripts tab In the middle territory This permits us to make scripts (programs) for the child Each sprite can have a few scripts This region demonstrates the present sprite
Slide 15Respond to Arrow Keys Click on Control (orange) and after that drag out "when space key pressed"
Slide 16Respond to Right Arrow Click on down bolt by space and select right bolt Click on Motion (blue) and drag out "move 10 steps"
Slide 17Change the move sum Click on the 10 it will highlight in blue Type 5 and press enter
Slide 18Respond to Arrow Keys Click on Control (orange) Drag out "when space key pressed" Change "space" to "left arrow" Click on Motion Drag out "move 10 steps" Change it to - 5 (to move left) Click on the stage and experiment with the left and right bolt keys Does the sprite leave the window?
Slide 19Paint a Ball Click on the paint brush and star It will state "Paint new sprite" in the event that you drift over it
Slide 20Draw the Ball Circle device and eyedropper Click the circle instrument and after that utilization the eyedropper to pick a shading and afterward click in the attracting range and drag to make the ball Drawing zone Click alright when done
Slide 21Size the ball as fancied and move it to the top Click and drag the ball to the highest point of the window
Slide 22Make the Ball Fall When the green banner is clicked we need the ball to dependably begin at the top and tumble down Click on Control (orange) Drag out "When green banner clicked"
Slide 23Start the Ball Click on Motion (blue) Drag out "go to x # y # " this will dependably begin the ball at its present position (Scratch doesn't consequently return it for you).
Slide 24Sequential Execution One square is executed after the other all together start to finish When the green banner is tapped the ball will go to the predetermined x and y area
Slide 25Loops We need the ball to keep on moving down unless the child gets it How would we get this going? We could utilize heaps of squares in a steady progression But, that would be moderate and monotonous We require an approach to rehash a piece or set of obstructs This is known as a circle or cycle
Slide 26Make the ball fall Click on Control (orange) drag out "forever" Click on Motion (blue) drag out "change y by 10" Change it to - 1 Try it out!
Slide 27Catch the ball! On the off chance that the ball touches the infant then it is gotten Let's track what number of balls we have gotten with a score We will augment the score every time we get a ball
Slide 28Variables If we will monitor the score We need something to hold the present score And we need to have the capacity to change the score We need the esteem to change or differ This is known as a variable
Slide 29Track the score When we begin the diversion set the score to 0 Click on Variables (red) Click on Make a Variable Name it score
Slide 30Set score to 0 In the ball script Drag the "eternity" down Drag out "set score to 0" Drag the "eternity" go down Notice the score appearing on the window
Slide 31Conditionals We need to build the score if the child got the ball So this activity will just happen just if some condition is genuine This is known as a contingent or an "if"
Slide 32Did we get the ball? From Control drag out an "if" Check if the ball is touching the infant Get this in Sensing If this is genuine addition the score From Variables
Slide 33Increment the score Try it out! is this what you anticipated? PCs do what you instruct them to Not what you need them to
Slide 34Reset the Ball If we got the ball Increment the score And move the ball to some arbitrary spot at the highest point of the window So we don't continue expanding the score
Slide 35Reset the Ball Click on Number drag out "pick irregular 1 to 10" drop on the x esteem after "go to x:" change the 1 to - 235 and change 10 to 235 change the y esteem to coordinate the y in the principal "go to x # y #"
Slide 36Adding Losing If the child doesn't get the ball it just stalls out at the base of the screen Let's tell the player that he or she lost
Slide 37Add a content sprite Click on the Paint new sprite catch Click on the T for content Pick the shading Modify the text dimension Move the square to where you need the content Type You Lost!
Slide 38Hide the sprite We would prefer not to tell the player that she lost when the amusement begins So shroud the message when the diversion begins Click on Control drag out "when green banner clicked" Click on Looks drag out "cover up"
Slide 39Check if Lost If the y position gets close to the base (close - 180) Drag out an if from Control Drag out a clear < clear From Numbers Add a y position From Motion Type in - 175
Slide 40Broadcast a message Sprites convey by passing messages One sprite communicates the message Other sprites can listen for it and respond to it when they get it Click on Control drag out "broadcast blank" tap on the drop down bolt next to new – name it lost Add "stop script" to stop the eternity circle Sprites impart by passing messages One sprite communicates the message Other sprites can listen for it and respond to it when they get it Click on Control drag out "broadcast blank" tap on the drop down bolt next to new – name it lost Add "stop script" to stop the eternity circle
Slide 41Receive Lost Click on the content sprite Click on Control drag out "when I get blank" tap on the down bolt and select lost Click on Looks drag out "show" Click on Control drag out "stop all" to stop all scripts
Slide 42Parallel Execution We have a few things happening in the meantime when the green banner is clicked This is called parallel execution More than one thing happening at once
Slide 43Create Instructions Click on the Show Project Notes symbol in the upper right corner Add the guidelines Press OK
Slide 44Test your game Click the green banner If you need, alter the speed of the ball Increase the sum it changes in y Modify the sprites utilizing the "Outfit" tab Save your diversion with the "Spare" catch
Slide 45Share your diversion You can share your undertakings at the scratch site http://scratch.mit.edu Click on the Share! catch You can likewise download different activities and perceive how they were made
Slide 46Other Ideas Add a sound when you lose Add the capacity to win When you achieve a specific score Track the measure of time it takes also Speed up the ball over the long haul Add more sprites to catch Add a sprite to maintain a strategic distance from (like a major sibling) executioner sprite
Slide 47Concept Summary Variables can hold values and can change esteem Forever circles rehash every one of the charges within them each one in turn until the script is halted or all scripts are ceased Conditionals – uncertainties just execute the body of the if when the condition is genuine Sprites can pass messages and get them Sprites can respond to occasions like tapping the green banner and squeezing the left or right bolt keys Sprites can have a few scripts, ensembles, and sounds Things can happen in a steady progression – consecutive execution or in the meantime – parallel execution
SPONSORS
SPONSORS
SPONSORS