In the Sensing panel, drag a (mouse y) bubble into the set y variable. Attach a forever ↺ block, and within that add the set y to block from the Motion panel.ģ. Select the player's Paddle sprite and add when the flag button is clicked in the code area.Ģ. There are two paddles-the first one, on the left side of the game screen, will be controlled by the player.ġ. Inside the statement, add turn ↻ set to 180 degrees, move set to 15 steps, and a wait block with 0.5 seconds.Ĥ. Click the sensor's dropdown to select Paddle.ģ. In the Sensing panel, drag into the if statement's bracket.Ģ. When the ball does touch the paddle, then it will bounce off the paddle.ġ. The code will ask: "Is the ball touching the paddle?" over and over. In this code, the question will always be asked, because it's in a forever ↺ loop. The if then block is like a question: if this happens, then this will happen because of that. If you take a slice from the pizza, then the number of slices will go down by 1. As an example, imagine you're eating a pizza. Kids will need to add some “if/then” blocks to complete this feature. Add another when the flag button is clicked to block the code area.Ģ. To hit the ball, it'll have to sense when it's touching the paddle.ġ. Right now, the ball will pass through the paddle instead of bouncing off of it. Read More: How to make a Snake game in Scratch In this case, the paddle will act as a sensor. Sensors are blocks of code that can track the player's movements or sense when one sprite is touching another sprite. Inside the block, add move with 20 steps, turn ↻ with 1 degree, and an if on edge, bounce block. Attach a go to x, y block set to 0, 0 and a point in direction block set to 45.Ĥ. Add when clicked to the Star (or Ball) sprite's code area.Ģ. Set the copy's x, y position to 216, 0.ġ. Set the paddle's Direction to 0, and its x, y position to -216, 0.ĥ. Click "Choose a Sprite" and add the "Paddle" sprite to the project.Ĥ. Kids can also change the sprite's size property if they think the sprite looks too big or small.ģ. Set its x and y position to 0, 0 in the sprite's properties. Click "Choose a Sprite" to find the "Star" or "Ball" sprite. Click "Choose a Backdrop" to find a background for the game.Ģ. There’s always time to customize further later!ġ. We recommend using pre-made sprites (from the "Choose a Sprite" database in Scratch) while they're setting up the code. Set up the spritesīefore they start coding, kids should pick out their sprites and position them against the backdrop. Kids will need a few basic elements for their game: sprites, sensors, a scoreboard, a ping pong ball-inspired icon, and, of course, a fun backdrop! Here’s a step-by-step guide to creating a customized masterpiece in Scratch. The player will control a paddle with their mouse and hit a ball to earn points!įor a quick preview, take a look at the game below to see what kids will be making. In this tutorial, we’ll walk through one of the easiest games to create on Scratch-a custom version of Pong, using variables to keep track of the player's score. They might have already learned how to create a sprite in Scratch, or even tried their hand at coding their first Scratch game: and if so, making a pong-style game in Scratch is a great next step! Scratch, one of the most beginner-friendly coding languages for youngsters, is as simple to use as it is fun! So, if your child has shown an interest in the program, here is the perfect challenge to take their new coding skills to the next level.
0 Comments
Leave a Reply. |