In this Scratch tutorial you will learn how to make a pong game part 2/2.
Tags:How to Create a Pong Game Part 2/2- Scratch,adobe software tutorials,adobenicnacs,crate games in scratch tutorial,create pong game,digital manipulation,scratch
Grab video code:
Hello and welcome to this tutorial for dominicask.tk. And in this video I’m going to showing you how to make a very simple pong game in scratch. And the next tutorial after this I’ll be showing you on how to develop this into a more fun game whereas pong games go. Which will have instead of just a paddle at the bottom it will have a paddle on the left, on the right and on the top. To sound like a bit more interesting but for now we’ll start the basics.
So here open is the one of the demo games comes from scratch. Just go to open and then you go to home. You won’t go to home, you come to projects, I’m sorry. Go to games, go to pong and you come to this. So you can just play it quickly to see what you get. And once you bounces you’ll hear the sound effect. You might not hear it because I use a head set. This is not the most intriguing game but it’s start, so we just stop this and go New and don’t save and will start a new project. You’re just going to right click and delete the cat. Click to paint a new sprite and zoom out notch got the rectangle choose a red color. And draw this out, I’m going to grab actually I’m going to press okay. And draw this down here with the long end notch. And make sure it is in the bottom just so it’s going to perfect there we go. Brand new sprite and zoom out notch grab your circle tool and choose a color, just grab this blue and hold shift and drag out to draw a perfect circle. So you just name this ball one, and the red one dead area, if you like a better name. This is the area where you die if you did, well the ball not you.
Going to control when green flag is clicked, first of all we want to reset the balls position in every time so I’m just going to go to motion. And every time you flick to it so anytime you panel in a tap over the motion. When you flip to motion, you’ll certainly go to XY to wherever its current position is, it’s quite nice to us. So we now know that whenever we stop the game it’s going to go that position there.
I just want to drag the direction down here and then I’ll be going to do is when we apply plate forever, before each bounce this means they, when they touch the edge it will bounce in the appropriate direction. So if it comes like this, it will bounce hence like that, it’s coming like that. It will bounce like that, you got the idea.
So what I’m going to do is to reset this and then what we’ll going to do is add a move say 4 steps. That’s what’s is used in the demo so we’ll just press the green flag. You see it’s nicely bouncing around the screen. So just stop it there, so next what we want to do is make our paddle. So paint a new sprite grab our rectangle tool and extract out a rectangle. Move this paddle we should drag it down here and we want to go when green flag is click forever. Set X to mouse X, what’s this going to do is preview here. You can see although it doesn’t interact the ball yet whenever my mouse set is where the paddle will be.
Next we add a script to the ball and I want to say when green flag click forever. You see I could do this next script all in here but keep the code clean and you organized it is best to do it in separate ones. It’s not going to make any difference here but it just makes more clean and organized. So what I’m going to do here is when that’s click forever then we’ll scroll down and grab if each statement. By the way if you don’t know want to watch this video in HD you might want to watch in HD because you’ll see all the code and everything a lot clearer crystal clear. If there’s no watching HD option at the moment it usually takes about 6 hours for it to appear after the video is upload it so come back watch the video 6 hours time issue it should be fine.
When the green flag click forever if then we might say touching paddle. And then we need a special bit of a code this is a special piece code that when it’s touch again it will bounce for us. Because there’s no code could tell that like a bounce option so we have to make our own. So what we do is to go point in the direction and we grab aside from the number is the minus block. We want to say 180 so points to direction the number 180 -direction. But this only works for flat horizontal surfaces this vertical, it won’t work, if it’s diagonal it won’t work. I think you get the idea. So it comes on here it will bounce.
So if we just do a quick preview, you can see we have that bounce in them. Next what we need to do is we’re going to quickly import a sound effect. We’ll go to effects you got the pop sound. And then we’ll just go play sound, pop, if it touching the paddle so lock set if you can hear this I got headset on. If you can that’s okay, if you can’t try this out for yourself then it’s fine. What we need to do is to make a little more interesting. As you can see if you go this it’s just keep going in a flat diagonal line. The angel change is going to be exactly the same, although it’s pop isn’t going to be should in terms on how physics would work. What we can do is we can add a turn this direction so turn clockwise and then go to number do pick random and then we’ll do -20 to 20. so it’s going to change that value between -20 and 20 so it could go down 20, got 20 bits, it’s going to be 40 range. So now we can play this.
You could see although if it really roll on the dead flat surface like this it wouldn’t go like this. It makes the game a tad more interesting, and what we need to do now is program in this script when it touches the dead area. So do when green flag is clicked forever if, by the way you saw them, I just snapped that back into perfect position there. What you do is right click and you press cleanup and use all the time makes my encoding a lot later. So when green has clicked forever if touching dead area.
Now you include as in the example just go stop all, what we’re going to do is we are going to crack this sprite, we will fill it with black and some create a new text we type in YOU LOSE. You can’t see it because it’s black but if I highlight it you can see that? You just switch the colors around to make it white, increase the size. And you can’t see the handle for the text but if you just move around a bit you should be able to grab it. Roughly center it, but you lose screen and we’ll grab when green flag clicked let’s hide. And then when the ball has touching the dead area we broadcast YOU LOSE.
That’s what broadcasting does is it yells out effectively so using a bit of personification here calling out. Imagine their actually alive this sprite will call out and send this message out to the other sprites. And when we touch the ball right here, and you can tell which sprite do some when they hear it. Now look so you go when I receive so what does sprite will do when it hears the yelling out lose, this is what it’s going to do. And what ‘s it’s going to do is to going to go looks and it’s going to show itself and it’s going to go stop the whole game. So we run it, we can play, we get sound and when it touches you lose. And when you press green flag and it starts again, and of course you can run this in full screen motor to see what exactly what it looks like.
Okay I hope you’ve enjoy this tutorial and check beck for next tutorial. I promise you’ll be a lot more exiting be have to grasp the basics of the simple pong game first, so I like to say I hope you enjoy this. Please comment, rate and subscribe to my videos. If you like of course, and check out my site that’s www.dominicask.tk. And other than that, thanks for watching.