 I feel like my videos have been getting too long lately, so I'm going to make this a quick one. We're going to be making a game, a bubble popper, a balloon pop game. Very, very simple, very, very quick. Godot engine. Yes, I'm using game engine to make a game. That's a first for me, right? Let's get going. Okay, fresh project in Godot. I've got some assets here, just a pop sound, a pop sprite that I made, and then I made a little icon out of that for it. So we're going to go ahead and drag those resources over here, and then we can close my file manager. Now, let's go ahead and we'll start with a scene for the balloon first. So we're going to say scene. We're going to change this. We're going to say change type to animated sprite, sprite animated. And I'm going to call this balloon. And then we're going to come over here. We're going to go new sprite, animated sprite. We'll come here, choose this and vertically it is two. And three. And then for the default, we're going to go one, two, three. And then we're going to create another one. We're going to call this death. And that's the balloon popping. So again, choosing the same one, we're going to go one, two, three spam call. And we will select those. Now, I also want the last frame of this animation to be clear. It's probably a better way of doing this, but I'm going to cheat. I'm going to come in here. I'm going to choose this again. And I'm just going to up these numbers a bit on both of these and then choose a corner that is not, doesn't have anything in it. Okay. And we're going to turn off looping for death. Okay. We should be good on that now. Let's go ahead and zoom in here. I'm going to now add a child for this. We're going to say an area 2D. And it needs a collision shape. So collision shape 2D. Go ahead and make that probably a capsule would be best. Like so. Give it a nice click. It's almost a circle, but we'll go collapsible or capsule on that. And then we will also add in a, an audio 2D that way it's in stereo. And I will call this pops SMD for pop sound. We're going to come over here and we are going to say that we want to well first add the sound, choose that sound, turn off looping. And then I click this little path button there and that should reload it. So it does not loop when it loads. One more thing we want to add is we're going to add a child and it's going to be a visibility node. And what this is going to do is going to let us know when this thing leaves the screen. So basically if you don't pop it and it continues going up the screen, you don't want to continue forever because it's going to eat up your memory when you start getting hundreds or thousands of balloons depending on how long you play. So we want, when this goes off the screen, we want to make sure that it frees up the memory. So let's go ahead and real quick we're going to add a script for this. We'll just call it balloon.gd and I am going to cheat. And I'm going to copy and paste all the code and go through it just again. So you guys don't have to see me type everything. First thing we're going to do set a speed random range. Well, this matter is we're going to reset that later. But if you call the balloon without setting a speed, this will automatically select something between 100 and 200. We're going to go dead false is going to make sure that we check that it's dead. That way once we click it, we can't click it anymore. And then also wait for a bit for the animation to play before the queue is freed. Next, when it's ready, oh, sorry, we also want to get the sound node and we're going to call that pop snd so we can call that easily inside our code. We're going to play the default animation. This hue shift, we'll talk about that in a minute. For right now, I'm actually going to comment that out. That's a little extra thing at the end to shift the colors over. Now, we're going to say process, we're going to, when it's processing, it's going to go over and over again. We're going to take the Y coordinates. So that's the up and down on the screen. We're going to subtract the speed times Delta Y times Delta. That keeps it moving at a consistent speed. Even if your computer is super fast or super slow, it will take that time that it takes for the loops to go through, multiply it by the speed and should keep it at a constant speed regardless of the speed of your machine. Hue shift, again, we'll go over that later. That's a shader, a little bonus thing, shader. I did not write, but I got offline and it works great. I've used it in more than two other projects. Okay, so it's constantly processing. And then we want to go here. We want to go, okay, when this area 2D, when the input event happens on it. So we're going to click that, connect it there. Very written out here, the same. If the event is a mouse and it's left mouse and it's being pressed and our balloon is not dead, we're going to set our balloon to dead. So now it's blue, it's dead and we can't click on it again. And we're going to run the pop function. That's going to play our sound. Play our death animation. Wait one second, then free the cue. Why wait one second? So we can see the play animation. Again, there's got to be a better way to do this. I Google it before and I have not seen this. This is how I normally do it. Probably not the best route, but we'll play that animation. Wait one second and free it. That's why we put that clear image as the last frame of the death. So that way it gets there, it stays clear. It's still kind of there, but you can't click on it and it will eventually clear out after a second. Next, we're going to say here, we're going to say this visibility notifier. When it exits the screen, we are going to free the cue. So once the balloon gets up off of the screen, it goes out of your memory. So it's not continuously eating up memory. We're going to go ahead and save this scene as balloon. Excuse me. We're going to now add a new scene. We will call this our main scene. We'll just call it main. And this will load in all of our balloons. It can hold other things if there's more aspects to our games, such as scoring, which we're not going to do, but it's very easy to do to count how many times you click and also count how many times a balloon gets off the screen without being popped. We're going to add a script. So attach a script. We'll just call it main. We'll create that. And again, I'm just going to quickly copy and paste just to save time. So this is a node 2D. We're going to set a float variable, which just means it's a number with a decimal for time and default time, which is three right now. And then we're going to say game time. And I'm going to start at 0.1. Why 0.1? Well, because at some point, I was dividing that number by something, and if it's zero, it would crash. Instead of doing an if-then statement to check, I just started it at 0.1. But I think I stopped doing that. So really, this could be zero. Let's go ahead and set it to zero and see if that crashes the game. OK, then we're going to preload that scene of the balloon. And we're going to call it balloons. And so we're going to use that down here in the create balloon function. So this is just preloading the scene. So it's there in memory. So we can grab instances of the balloon, instances just making copies of it basically. OK, we're going to take our game time and add delta to it. So this is actually, we do want this to be a decimal. It's basically just going to keep count how long the game's running, not counting pauses and background functions. So it just counts how long you've been playing for. Then we're going to take our time and subtract delta from it. So delta, again, is every time it loops, it's how long that loop takes. So basically, we're just saying, OK, we're taking the time and we're subtracting how long it's been from that. At any point, if time is equal to or less than zero, we're going to take time and reset to the default time, which is three. We're going to then take default time and subtract 0.1 from it. So what this is doing is saying, OK, we're starting off at three seconds. Every three seconds, create a balloon. But every time you create a balloon, shorten that time a little bit. So the balloons will start to be getting created faster and faster and faster more often. Doesn't take very long for it to get to the max and we don't want it to all of a sudden just spawn hundreds of balloons at once, which is what happens if it drops below zero or gets to zero. So we're going to say, OK, once you get to half a second, go ahead and set that to the max. We're saying if default time is less than half a second, set it to half a second. So our max speed is, balloons will be created every half a second. And then we're going to create a balloon. So how are we creating a balloon? First, we're checking our viewport size, so the size of our screen or our window. We're going to take that and then we're going to say, OK, we're going to get an X and Y position, but we're going to make the X random. So this will position the balloon from left to right randomly, but we don't want it going off the screen. So I'm just saying a number 64 here is making sure that we don't, the balloon doesn't appear right on the edge of the screen. It moves it over at least 64 pixels. Then we're going to get the size of the screen with, which is size X and we're going to subtract 64 again. So it does not go up the right side of the screen on the very edge. For where it appears up and down, we're going to take the size of the screen, add 128 so the balloon starts a little bit off the screen. Then we're going to take our balloons, which is the scene we preloaded up here, see balloons, spelt wrong. Let's go ahead and fix that balloons and we're going to make an instance of it, basically a copy of it and put it in balloon. Then we're going to say its position to a 2D vector using the coordinates that we just generated. So it's randomly placing it left and right just below where the screen starts and then we're going to get a speed, but the speed is going to be slightly different for each balloon. We don't want them all moving at the same speed, but we're also going to use the game time to, as the game goes, even though it's grabbing a random, it's grabbing random from a range, so that's why it ran range. We're going to start off, the first balloon is going to have a speed somewhere between 50 and 300, but then as the time goes on, every second adds to that so the balloons are going to get faster and faster, but again, some will be faster than others and they're going to add to the scene. That is our entire game. Let's go ahead and save the scene, main. Hit F5, it's going to ask for our main, what scene we want to be our default, we'll say main, and there we go. Our balloons are really, really small, but I should be able to click it. Oh, something crashed. Okay, let's go ahead back over here. So why are our balloons really, really small? Because I made a sprite that's really, really small. So what we're going to do is we're going to come in here to balloon and we're going to take transform, we're going to say scale. I think I did like 10 by 10. Let's see what that looks like now. Yeah, that's better because on a phone, they're going to appear smaller. Okay, so it's crashing on play, on pop sound, play. So, oh, did I, yeah, I dragged over the audio for that, right? Wait, what did I just clear out? Sound. Okay, let me see. Attempting call function play in basinal instance. Pop sound. Oh, because I created this under, there we go. I'm not sure what I clicked on a second ago. Let's see what happens now. Here we go. Now you'll notice there's little edges around my balloon animation and also they're kind of blurry. That's because it's such a low resolution. What we want to do is we want to choose the balloon down here, go to import and turn off filtering and re-import. That will fix that. If you have pixel art, you want to turn off filtering. That looks much better there. Again, it's very low resolution. It's a pixel art that I created. Could have done it higher. I don't know why I did that. I drew it by hand just for fun to put up on open game art like a year ago. And again, I've never used any projects up until now. But all our balloons are red. So real quick, let's create a shader. So, I'm going to go to my sprite here. I'm going to go down to materials. Materials, I'm going to choose a shader material. I'm going to choose this and I'm going to say edit. Oh, I think I clicked the wrong thing. Empty. Oh, new shader here. And then click on that. And now we're in an editor. And let me go ahead and bring up that code and copy and paste it. I'm not going to explain this, although I understand I have read through it before. Basically, it's getting the color and I think we're shifting the hues. So, a hue will allow you to shift colors. Now, let's go back into our code here. One thing I commented out was this hue shift. And right now I have it set to random of three. So it's going to be red, green, and yellow, I think, of the colors. Of course, you can adjust this if you want it blue or something else. Or make it completely random. And then there'll just be all shades of colors. But now that we did that, we should have green balloons, yellow balloons, and green balloons, red balloons. There we go. You know, some are moving, some are others. Now, it only takes like a minute or so and the game does start going faster. So, looking at it now, it seems pretty easy. It takes a while. So, let's real quick also, since this is going to be on a mobile app or a mobile phone as well, we're going to come here, come up here, we're going to say clear, which will bring us to environment. And let's go ahead and say, it's like a sky blue. We could have put a sky background, floating up in the sky. Oops, let's go a little more right there. That looks good. So, we're going to have a blue background. Nothing we'll want to do is, let's say, I mean, on a mobile device, you're going to probably always want to play this in a portrait mode. So, we're going to go to display, window, come down here. It's set to landscape. We'll set it to portrait. That will force it into portrait mode. Obviously, on a desktop machine, you can play it like that. You can play it like this. The code checks for the size of the screen. So, it's okay if you resize. Now, if I have it wide like this and a balloon comes up, like that one over there. I do this. I can't click it now. It's off the screen, but all the other ones that come in the future will be inside this window. That's it. Check out the link in the description. I will have a link to this project up on GitLab. There you can download it, give it a try. The assets and the code will be there free under a GPL license. I thank you for watching. Visit filmsbychrist.com. That's Chris with the K. There's a link in the description. As always, I hope that you have a great day. This video is still 15 minutes. It wasn't any faster than the others.