 Alright, what's up everybody welcome back from the reply game python programming tutorial I think that was the first time ever I actually said that without stumbling over my words now in this video We're gonna kind of continue with our world editor that we Built in the last tutorial. It was really simple. It was really really easy It didn't do much at all other than draw shapes, and we just kind of kept track of those coordinates Now if you notice, I'll go over back to the the engine that we have here We copied and paste all of the the Platforms that we made into the level structure for level one and there was there were a few cases or in fact in this case There were only one case there was only one case where we had a width that was negative And that happens if we actually were to draw I'll show it to you I'll show you I'll bring up in the play World editor here in this case if I drag my mouse and go diagonally right and down That's all positive if I were to drag my mouse and go Ta ta to the up direction and left width is gonna be negative if I hit the enter button If I drag this out here, you can see that. Whoa, this is negative and whoa, that's negative, too We can't really have a negative width or height so in pi game, this is called normalizing and I'll show you how we can kind of manipulate that in here and The way that we're gonna do that is actually by adding to draw In this to draw line once we create the rectangle the pie game dot wrecked if we were to run dot normalize The Z that immediately fixes everything To that specific rectangle so if I were to draw this right here. Okay. No, I'm an R. I'm an idiot. Sorry What did I do? The heck did I do? The heck did I do? All right? All right guys, I figured it out The normalize function does this change it it switches And it kind of corrects the negative sizes It switches the sides of the rectangle and it does that to the actual rectangle object It does not return any other object. It just does it to that object itself So the way that we have to do this in our code is actually say, okay Let's bring this out of the to draw addition program or line and let's say that the rect is equal to this And now let's run a rect dot normalize All we're doing is putting in a variable and then running that on the variable and then we just add in the rectangle That variable so now when we run the code, let's see what happens here If I run this that works just fine you can see it in the back if I run this enter That works just fine as well Okay, cool So there's our rect. There's our normalize function now Let's say what if we wanted to use already the stuff that we already created because I'm kind of curious to see how this level will work This is just honestly out of curiosity and just just for play But I want to show you guys how the normalize function works or at least one way that I know how the normalize function could work So I'm gonna show you this over in the block objects right over here We can expand or close out of the levels here and let's open up the block in the constructor. Let's actually do a few tests Let's uh Right after we after we call all this before we start to make things with width and height Let's test. Let's say if width is negative. That's when we know there's a problem, right? So if width is negative, let's flip the sides. Let's add width to x Now x now when that sorry width is negative, right? We just said if width is negative then this will happen is so if we're adding a negative number We're essentially subtracting so we subtract x which is the position Subtract the width so the sides will stay there the sides will say at the same place and Let's see. What if we do this? What if we have to set width to equal the positive version of width Which is the absolute value of width and of course we can do the same thing for height here That's that's that's super duper simple, right? If height Is less than zero then well why can of course equal Plus width sorry plus height and then we'll do the same thing Find the absolute value of that value Now when we run the code that works just fine for us the block is created a okay and boom We've got our dude just hanging out in this world that we just made and yeah Yeah, we got our we got our scrollable camera that we made in the last one to scroll the platformer If I just jump on these platforms here, I can hang out. I can move around I'll go down here. Let's say jump over here walk down these stairs. Oh Nifty we got a cute little video game, right? You can jump on these platforms I can jump on this here and jump all the way down and boom Now this world is very indefinite, right like if I were to jump down here Whoa, I keep falling forever because that's the way that it's it's just programmed even when we've made this level with the world editor It looks kind of just constrained like in the dimensions of the program that we made we can of course like okay What if we drew a big box? If we made all this crap Very dark, so we can't see the edges or anything It's like we just made a world. It's this tiny Like this right here in the center and I put right this right here and Maybe another block over here Kind of something coming from the wall. We can make whatever we want and That works okay for us, but Now we kind of have to know what are the coordinates and stuff. Where is the position? Well, what if we we need to be able to place the player in this in this in this world, right? We want the player probably spawned right in here Well, we don't really see how we can do all that we can get the coordinates, right? But we're kind of taking a guess as to where the player is in that case What if we kind of displayed the text? Hmm, I'm gonna leave that up to do what if we what if we had What if we had a coordinate system not a coordinate system? But if we if we displayed where the mouse was if we displayed the coordinates of the mouse every time we moved So you as the developer you would know, okay, where is what in this world? I? Don't know. That's that's up to you. You can make that I'll leave that as an option if you want to show off how you can do that Please do it might be good idea to make more of the game that you want, but that's one way to do it so Okay, I think I'm good. I think that's that's all I wanted to show off in this video Just simple normalizing this function right here how we can fix it now We can load that world and the way that it works or at least one way that can work since we're gonna use this Normalize function from now on we really didn't need to see this right here, so I'm gonna remove that And I'll just Go back to the level that we used to have or something What if I have an empty level? I can't really have an empty level. I mean I could right? Let's see what happens. This is just me goofing off. It's the end of the tutorial Whoa, I'm falling for days There goes gravity. All right. Thanks for watching everybody. I hope you're enjoying this. I hope you're enjoying the series I it's it's a lot of fun for me to make and and all that So I I do enjoy it Let's have a brown I Added brown the colors earlier and now we got a little brown ground And jump around with that cool. So yeah Hope you're enjoying the series if you like all the stuff that I'm doing if you have any questions comments Something that you'd like to see done. Just let me know subscribe like the video comment get involved Thanks guys. I'll see you in the next tutorial