CREATE PONG II GAME This is a two player game! To play Pong II: Press the green start flag. In three seconds a tennis ball will appear somewhere at the top of the screen and begin moving randomly toward the left or right side of the screen. The left-side player uses the 'q' and 'a' keys to move the left-side paddle up and down. The right-side player uses the 'p' and 'l' keys to move the right-side paddle up and down. Score is kept for each player. As the game progresses the ball moves faster and faster! Play the game before you start building it yourself! Start Scratch 3/7/15 Download Instructions Need Help? NEW CONCEPTS LEARN HOW TO: KEY NEW TECHNIQUE INTRODUCED: USE STANDARD CODE FORMS FROM EARLIER PROJECTS TO CREATE MORE COMPLEX GAMES CHANGE SPRITE MOVEMENT BASED ON SPECIFIC CONDITIONS Use the ‘nesting’ technique to apply conditions to If, Then code. 3/7/15 ADD GAME SPRITES TOOLS YOU WILL NEED You need a Ball and a Paddle and an additional sprite to be placed at the bottom of the screen for this game. Use the buttons on the New Sprite toolbar to create all three of these sprites. Click the Choose Sprite From Library button. Click the Sports category. Double-click the Tennis Ball Sprite. The Tennis Ball sprite will appear on the game stage. Now click on the Looks script option and drag the Set Size to … % block to the script area. Make the value be 50 as shown here. Click once on the Set Size to … % block and note that the sprite appears much smaller. 3/7/15 ADD GAME PADDLES ILLUSTRATIONS In this game you will continue the art of drawing your own sprites. Follow these instructions to draw to simple sprites. Click the Paint New Sprite button. You will see a screen with a grid under the Costumes tab. In the bottom right corner of the grid, click on the Convert to Vector button. You will see the controls move from the left side of the grid to the right side of the grid. 3/7/15 ADD GAME PADDLES (CONTINUED) ILLUSTRATIONS In this game you will continue the art of drawing your own sprites. Follow these instructions to draw to simple sprites. Click the Line button. Then, to make things a little easier, click the Zoom button in the bottom right corner of the grid. Click it twice so that the zoom % shows 400% The squares on the grid will become larger as shown here. 3/7/15 ADD GAME PADDLES (CONTINUED) ILLUSTRATIONS In this game you will continue the art of drawing your own sprites. Follow these instructions to draw to simple sprites. You can see a small cross in the center of the grid that signifies the center of the grid. Count about five squares up. Hold the Shift key, then Click and drag your mouse to draw a line from five squares above the cross, to five squares below the cross. When you release the mouse button, the line will appear in the game stage. This is your first paddle. 3/7/15 ADD GAME PADDLES (CONTINUED) ILLUSTRATIONS In this game you will continue the art of drawing your own sprites. Follow these instructions to draw to simple sprites. Change the name of the sprite to Player 1 and Player 2. Click the ‘I’ at the top left corner of the sprite icon. The screen will change to the screen shown to the left. In the name box at the top, type in ‘Player 1’. Then click the blue arrow in the upper left corner to return to the regular sprite display. Notice the name has now changed to Paddle 1. Right click on the sprite Player 1 and click on duplicate. See how it automatically created another paddle sprite called Player 2! On the stage you should now see a tennis ball and two lines for your paddles. Don’t worry about where on the stage the paddles are sitting, you will fix that later. 3/7/15 ADD GAME SPRITES (CONTINUED) ILLUSTRATIONS In this game you will continue the art of drawing your own sprites. Follow these instructions to draw to simple sprites. You must draw two more sprites for this game. Again, click the Paint New Sprite button. Name the sprite the same way you did for the Paddle. Change it to say Left Side. And again, click on the Convert to Vector button. You will see the controls move from the left side of the grid to the right side of the grid. This time, however, do NOT use the zoom button. If the Zoom stayed at 100% from when you were drawing the paddle, click the Zoom Out button to go back to 100%. At the bottom left corner of the grid, there is a slide. With your mouse, drag the slide bar so it is approximately in the center of the slide. You will see the line get thicker. 3/7/15 Now click the Line button. Draw a line across the center of the grid from the top to the bottom. ADD GAME SPRITES (CONTINUED) ILLUSTRATIONS In this game you will continue the art of drawing your own sprites. Follow these instructions to draw to simple sprites. The line will appear in the stage. Using your mouse, drag the thick line to the left of the stage and center it on the stage. Change the name of this Sprite to ‘Left Side’. Right click on the sprite and select Duplicate to create another line. Change the name to ‘Right Side’. Your completed stage should now look something like this 3/7/15 POSITION THE PADDLES BLOCKS YOU WILL NEED When the game is started, you want the paddles on the right and left side of the stage. Before you begin to create code for the paddle, make sure you have clicked on the correct paddle sprite. Position the Paddle sprite by moving it to a specific location on the stage’s X and Y grid. To do this, snap together the blocks shown at left. 3/7/15 SET PLAYER SCORES TO 0 BLOCKS YOU WILL NEED When the game is started, each player’s score should be 0. Create two variables, Player 1 and Player 2. Remember it doesn’t matter which sprite you create these under as long as you check “For all sprites”. The variable sprites will appear on the stage. Drag the Player 1 score sprite to the upper left corner of the stage. Drag the Player 2 score sprite to the upper right corner of the stage. Under the Player 1 sprite insert the Set Player 1 block unto the code. Under the Player 2 sprite insert the Set Player 2 block into the code. 3/7/15 ADD PADDLE CONTROLS BLOCKS YOU WILL NEED Each player uses a paddle to bounce the ball back toward their opponent. Player 1 controls their paddle with the q (up) and a (down) keys. Player 2 controls their paddle with the p (up) and l (down) keys. Build the same basic control script that was used in games you have built before. Using the Key … Pressed? Block, click the small black down arrow to see the list of buttons. For Player 1 you will need blocks for the q and a keys. For Player 2 you need blocks for the p and l keys. Finally, add the Change y by blocks. Use value 10 to send the paddle up and -10 to send the paddle down. Player 1 3/7/15 Player 2 Player 1 3/7/15 Player 2 POSITION THE BALL BLOCKS YOU WILL NEED At the start of the game, the tennis ball appears at the top of the screen and shoots toward the right side of the screen. Before you begin to create code for the tennis ball, make sure you have clicked on the tennis ball sprite. Create a script using the blocks shown to the left. This script will do the following: - When the green flag is clicked make the tennis ball disappear. - After three seconds, make the tennis ball appear at the top center of the stage (x=0, y=215). - Point the ball in direction 135 Show Me 3/7/15 3/7/15 CONTINUE BALL CONTROLS BLOCKS YOU WILL NEED In this game, after the players have hit the ball a certain number of times, the ball will speed up to make the game more difficult! In the Data script option, create a new variable called Hits. Uncheck the Hits variable, so that it is not visible on the stage. Move the Set Hits to 0 block to the script are and snap it under the script you previously created. Show Me 3/7/15 3/7/15 CONTINUE BALL CONTROLS BLOCKS YOU WILL NEED Set up all of the remaining controls for the ball. Under the script you have already created, snap the Forever block. Inside the Forever block snap the If on Edge, Bounce and four IF, THEN blocks. 4x 3/7/15 COMPLETE BALL CONTROLS BLOCKS YOU WILL NEED Set up all of the remaining controls for the ball. In each of the first two IF, THEN blocks, use the blocks at left so that: - If the ball touches the paddle of Player 1, have the ball bounce off of the paddle in a random direction between 45 and 135. - If the ball touches the paddle of Player 2, have the ball bounce off of the paddle in a random direction between 215 and 305. - Change the Hits counter by 1. If you need help, click the Show Me button (or go to the next slide). Show Me 3/7/15 3/7/15 COMPLETE BALL CONTROLS BLOCKS YOU WILL NEED Set up all of the remaining controls for the ball. In each of the next two IF, THEN blocks, use the blocks at left so that if the ball touches the side of the game it changes score etc. If the ball hits the Left Side sprite (the left side of the screen): - Change player 2 score by 1 - The ball disappears for three seconds - The ball moves to position x: 0 and y: 215 - The ball is pointed in direction 135 to start the next round - The ball reappears - Set the Hits counter to 0 If the ball hits the Right Side sprite do the same as above except: - Change player 1 score by 1 - The ball is pointed in direction 215 to start the next round Show Me 3/7/15 3/7/15 CHANGE THE BALL SPEED BLOCKS YOU WILL NEED Build the code that will make the ball go faster as the game progresses. With three IF, THEN, ELSE blocks, and a single IF, THEN block, build a nest that will contain the code to make the ball move faster the more times it has hit a paddle. Show Me 3/7/15 3/7/15 CHANGE THE BALL SPEED (Part 2) BLOCKS YOU WILL NEED Build the code that will make the ball go faster as the game progresses. In the first IF, THEN, ELSE block, use the blocks at left to tell the ball to move at speed of “8 steps” if the ball has been hit less than 5 times. Show Me 3/7/15 3/7/15 CHANGE THE BALL SPEED (Part 3) BLOCKS YOU WILL NEED Build the code that will make the ball go faster as the game progresses. In the second IF, THEN, ELSE block, use the blocks at left to tell the all to move at speed of “10 steps” if the ball has been hit more than 4 times but less 9 than times. In the third IF, THEN, ELSE block, use the blocks at left to tell the all to move at speed of “12 steps” if the ball has been hit more than 8 times but less 13 than times. Show Me 3/7/15 3/7/15 CHANGE THE BALL SPEED (Part 4) BLOCKS YOU WILL NEED Build the code that will make the ball go faster as the game progresses. In the final IF, THEN block, use the blocks at left to tell the ball to move at speed of “14 steps” if the ball has been hit more than 12 times. Snap the entire nested IF, THEN set of blocks onto the bottom of the remaining script (but inside the Forever block and you have completed the game construction! Show Me 3/7/15 3/7/15 PLAY THE GAME Try it! Click the green flag above the stage to start the ball moving. Complete Hints 3/7/15 3/7/15
© Copyright 2026 Paperzz