 So one of the things I like to do when I'm making video games, I really like games where you're a spaceship flying through space and you have the background you want it to scroll constantly, infinitely, seamlessly. That's what we're going to go over today in Godot. We're actually going to create a very simple background, it's not going to be beautiful, but that way we have a seamless background to scroll and then I'll show you really it's just one line of code once you set up the nodes in Godot. So let's go ahead and check that out. Okay, here we go in Godot, got a new project going here. And so let's go ahead and start creating our scene. I'm going to create a 2D scene. So it's 2D node. We can rename that if we want level or you know, this might be a space level. So we'll say call it space, whatever you want to call it. That's fine. Let's go ahead and save that control S and save it wherever in your project. You know, obviously in a real game, it'd be part of a bigger project. Okay, so we're going to add three nodes here, one under another. We're going to add a parallax background and then to the parallax background, we're going to add a parallax layer and then to the parallax layer, we're going to add a sprite. Okay, so make sure that the parallax background has the parallax layer underneath that and the sprite is under that. Okay, next we're going to need an image, a seamless image that will scroll forever. So I'm going to go into Gimp real quick and I'm just going to create something real simple, just like a background here. I want it to be vertical in this case because I'm going to make like a space, you know, you're flying upward is what I'm thinking for this. We got 1080p here. I don't necessarily need it to be that high of a resolution. So I'm going to do, I'm going to do half that. So I can just, most programs, if you have a number like this, I don't know if you know this, but you can just do math in here. So if I want exactly half of a 1080p, I do that divided by two and then I'll do the same here divided by two and it will do the numbers for me. We do want to remember that this is 960 high because that's, we need to know that for when it's looping that we wanted to mirror itself seamlessly at 960. Okay, and here I have a black background and I'm going to choose my paint brush and I'm just going to put some fancy stars like so. And it really doesn't matter for this tutorial, but let's go ahead and try to make it look a little bit nicer. We'll blur those out, maybe blur them out a little bit more. And just for fun, we'll make it seamless. So we'll go down to filters, mapping, and we'll go tile seamless and it makes it a seamless image in this case, both left and right and up and down, even though we are only worried about up and down at this point. I'm going to export this and I'm going to save it to my project as background.png or jpeg, whichever you prefer. And then we will go back to Godot. Now in Godot, we have our sprite selected here and I'm going to drag over that background right to there. Okay, if I hit F6, it'll load up this scene. You can see that our sky is up over this way. Let's go ahead and close that. If I scroll back, we can see our viewport here. But even if I place that somewhere in the middle here and start up the scene, again, F6, it's not centered. It's not filling up the whole screen. That's because my screen is resizing here. Let's go ahead and go to project and we'll scroll down here and we'll go down to display window. Now you can set your project height. Again, if you don't know, you want some intervals of or something evenly divisible of standard screen widths and heights. For 1080, we can again do divide by 2 and we'll do the same thing here for height, 1920 divided by 2. Of course, this is going to give us a tall window, which is something we kind of want for this video. But we also need to come down here to stretch mode. We're going to set this to viewport and we are going to set this to keep the aspect. Close. Okay, now I have this. I can center this up on here and I can hit F6. And you can see it's now there. We have blackboards. Now, if we didn't want the screen, since most people don't have their screens on a phone, that would be pretty good there. But on a desktop, we would have these reversed, right? So this would be 960 and this is 540. I'm going to show you this just so you're aware of both ways. And again, you can see the purple here is our screen. I'm going to turn on snapping here and just try to center this up a little bit. Does that look good? Maybe a little more over here. Okay. And if I hit F6 now, you can see it's centered up. But I want this to fill the whole screen. So there's a few different ways you do that. If you have a camera, you can zoom it in. But what I'm going to do here is I am going to scale up my sprite, which is, you know, I'm going to scale it up later so you can see what I'm talking about. So we have our image here. It's not moving and it's not repeating. So first thing I need to do is I need to come up here to our parallax layer that is the parent of our sprite. I'm going to go to motion. And we're worried about why in this scenario, why is up and down? Remember I said it was 960 was the height and that's important. We're going to put that in there. And now you can see that it just mirrored it. So we have it mirrored, but it doesn't move yet. To make it move, we're going to attach a script. So I'm going to attach a script to our parallax background here. I'll just call it parallax background. And under the process function, I am going to say dollar sign, parallax layer dot scroll. You know, I'm sorry, it's not to the parallax layer, but to the parallax background, we're going to say scroll offset. We'll have that. And we want it to scroll on the Y again, up and down. And we're going to take what it currently is at and we'll add 10 to it each time this loops. So we'll go ahead and we'll hit F6 now. And we have our scrolling background. And it will scroll forever and ever. It is now infinite, but we still have the black sides here. So what I'm going to do is I'm going to choose my sprite. Now I'm going to transform it and I'm going to double its size on both the X and Y to keep it. But now you notice the seam doesn't look right, right? If I run F6 now, it does fill up the whole screen, but we see that line and then it kind of jumps. We don't want that. Well, we know that we doubled it in size in the transformation. So if I go up to the parallax layer here, this Y now, we want to double that. So if it's not a round number that we know, we can just say times two and now it's 1920. And if I hit F6, we now have an infinitely scrolling background that fills most of our screen. I'm not full screen now so there's black bars on the side, but there's different ways depending on your setup to handle that. But yeah, that is how you create an infinitely scrolling background. If you want to make a space shooter now, you're all set. Just throw yourself a seamless star background. And even though your objects aren't really moving up on the screen, it looks like it. So, oh, no, there is something else I want to go over. We did this and it works, but there is something that's not quite proper. We want to use Delta. Why do we want to use Delta? If you're older like me, you may already know the answer. If you're younger, you may not. Or maybe you do, who knows. So back in the day, people made games on old hardware. They made it run as fast as they could because the hardware was slow. Then what happened was computers got faster. The games would run too fast and they were unplayable. What we have here is Delta is basically the time elapsed since the last time this looped. And if we, so in most cases, it will be a fraction of a second. And what this will do is it will keep the speed of the background consistent on all machines. If the machine is running slow, the background isn't going to slow down. If it's running super fast, it's not going to fly super fast. The thing is we're now multiplying the number we had before by a fraction. So it's going to be a fraction of what it was. So before it was 10, now we're going to do 100 times Delta and it's still going to be pretty slow. So I'll run this and you'll see it's moving rather slowly. We'll go back into the script. Let's bump that all the way up to 1000 and have a look at it. There we go. But now because we're using Delta, regardless of the speed of the machine, we should get a consistent speed. Now if the computer is running really, really slow, it's possible it will look jerky but it will move at the same distance per loop. So there's that. Just doing things properly. So that's it. I hope you found this tutorial useful. Please visit filmsbychrist.com. That's Chris of the K. There's a link into the description. And as always, I hope that you have a great day.