In this video, you’ll make the ball sprite bounce around the screen. There are a lotof blocks in the “motion” menu in Scratch that make the sprite move in different ways.
The simplest way for a sprite to move is in the direction it's already facing.
Click on the ball sprite. From the “motion” menu, drag out the “move” block. Clickon it. The sprite moves, but only once. It needs to keep moving.
In activity 2, you used a “repeat” block to make the sprites repeat their change costumeaction. But, that made the action happen a specific number of times, then stop. In thisproject, the ball should keep moving. From the “control” menu, place the “forever”block around the “move” block. Click this stack and test it. The ball spritemoves... until it hits an edge. Computer scientists call problems in theircode “bugs.” The “if on edge, bounce” block from the motion menu will fix this bug,so the ball can keep moving. If you click on it, it seems to do nothing. But, when youplace it inside the forever loop, the ball sprite starts bouncing around the stage. Prettysweet. Right now, the ball will start moving in apredictable direction, which makes the game easier. To make the ball start moving in arandom direction, from the “motion menu” place a “point in direction” block ontop of the forever loop. To make it choose a random direction, from the “operators”menu, place a “pick random” block inside the “point in direction” block. Tinkerwith the numbers in the “pick random” block until you find ones you like. This exampleuses -45 and 45. Finally, make the ball sprite start movingwhen the flag is clicked. Place a “when flag clicked" block at the top of the blockstack. Click the flag. The ball sprite will start moving.
Here’s the game plan: Make the sprite move with the “move” block.
Make it move forever with the “forever” block and bounce with the “if on edge, bounce”block. make the ball start moving in a random directionusing “point in direction” and “pick random” blocks.
And finally, add a “when flag clicked” block to the top.
After the ball sprite is bouncing around the stage, move on to the next video to get theathlete sprite into the action.