
Your coding area for the Ball should look like this.
Place a “when green flag clicked” hat block on top.From the “Sensing” palette, drop a “touching (mouse-pointer ▼)?” block into the “” placeholder.
Place an “if then” block inside the forever loop block. Select the Ball sprite, then drop a “forever” loop block next to the stack of blocks we placed earlier. No such block exists for sprites contacting other sprites, so we have to make our own.ĭon’t worry, champ. It was easy to make the ball bounce off the edges of the stage because Scratch provides the “if on edge, bounce” block. The logic we want to implement here is “if the ball is touching the paddle, then bounce.” Step 7: add code to bounce the ball off the paddle. The ball should be bouncing around the stage, and you should be able to move the paddle side-to-side with the mouse. Click on it if it’s not.Ĭlick the green flag icon above the stage to set everything in motion. It will appear on the stage and in the Sprites area next to the ball. Click the “Choose a Sprite” icon and select the green ”Paddle” sprite. Now let’s place another sprite for the player to use to hit the ball - the paddle. Multiple scripts can each wear the block and all activate at the same time, running in their own separate processes. S cripts (a stack of blocks, like those pictured above) that wear this block “listen” for the start event and will activate when they hear it. When the green flag icon above the stage (the Go button) is clicked, it sends a start event in your project. The “ When Green Flag Clicked” block, commonly called the “ Start Block,” is a “ Hat Block” that listens for a Start event. The ball should be moving around the stage, bouncing off the edges. Remember the green flag icon above the stage I mentioned earlier? Can you guess what it does? Click on it, if you haven’t already.