 What is up, ladies and gentlemen? Welcome back to another PyGamer Python programming tutorial. In this video I'm just going to clean a few things, kind of make a few small changes just to make the code a little bit better in my opinion and probably in your opinion once we get to it. So you might have seen me blaze right ahead. In the player object I'm just going to kind of shrink him down. He's a little bit too fat for my liking. I'm going to use a width of 32 and a height of, in this case 48. Pretty simple. I'm going to tighten up the set properties function. I'm going to keep this self dot speed variable. In fact I'm going to enhance that. I'm not going to be using the change speed function too much anymore. I'm going to get rid of that. Self dot set position. I probably won't use that much at all again either. Right now I'm just going to comment that out because I might actually want that because that actually deals with our origin. So yeah that'll probably stay. Okay, the change speed we're going to have to worry about. We're going to fix that up. Self dot image. Setting images. Actually I learned this later and I actually should probably tell you it now before it's too late. Once you have loaded an image it might be a good idea to go ahead and convert it. You can use dot convert afterwards. If you don't throw it into this nested linear version you should use self dot image is equal to what self dot image already was and then convert it. What this convert function does is it kind of does some pie game preparation that gets it ready for alpha processing I think. There is a convert alpha that you should look into and that sort of thing. You can look at more information about this online in the pie game documentation but for now I just want to have this self dot image equals pie game dot image dot load file name convert. Just a small change. Set properties we're going to keep that just there. Actually we're not even using this set image function for the rest of it but okay I mean I am going to delete it but I wanted you to know that you can use the convert function there. Wow it's a lot of me talking for no reason. Okay in the self dot update function I'm not going to make too many huge changes I'm not going to actually include this comment anymore because I think we should be able to read it on our own. I'm going to open it up a little bit however and kind of tighten things around here. Okay now in our handling for the control handling H speed is actually okay maybe I've already changed it but yeah I do not want to be using the self dot change speed function anymore. This might be different from your code that you might have but self dot change speed should not be run. We're actually going to keep it to H speed can equal this negative self dot speed. If you remember the change speed function was actually adding this new variable to what it already was and I don't want to keep that functionality. I want to be able to immediately change direction no matter which way I'm going. Same thing happens with V speed we're actually jumping so we're going to multiply that by two if you remember and for the down key since we have gravity nothing that is actually really happening. For the up button we're actually testing this sort of thing or actually testing if we're moving left or right and in that case that's when we would change. You might want to change to this in your code. Test whether H speed is actually moving in the left direction if it's less than zero and then set it to equal zero and same thing happens for right if H speed is greater than zero which means we're moving in the right direction then set H speed to zero. Up and down nothing happens because we have gravity and because we have jumping so we don't have to worry about that. The experience gravity function looks pretty okay to me so let's leave that just the way it is. The block function we're not going to worry about the origin anymore I'll actually remove that commented code keep the self dot rect and I suppose that's all I really need for now. Level looks good to me, update looks pretty good to me all in that. I think everything looks pretty good. I won't really be using the set message function anymore though it is probably good to have. I am unfortunately going to delete that I don't know why I said that weird it sounded like I had an accent there. We can set the title it doesn't have to be subscribed anymore by gaming it just works just fine for us active player list. Oh the set position function is being called here okay I remember I wanted to have actually a certain position for the player to start in each level. Let's go back to our level class our level object over here and let's actually set up some variables for self dot player start. I'm going to set that equal to self dot player start x and of course self dot player dot start y. I'm going to probably have to go back slash into a new line here look and start at zero by default and zero for y by default as well. This back slash allows me to carry the code onto a new line that might be a nice tactic for you to keep in mind. And yeah I guess for now that works for us we just have a player start object and let's see let's keep moving I guess. If I wanted to have that set up with the player start we're probably going to want to change something in the player object itself because we're using we're actually telling the player's level to equal something when we have our main function we set player level is equal to current level but maybe we should have a function that actually sets the level and then sets the player's position to equal whatever the level's current place is. So I'm not going to have any specifically defined thing for level zero one because it's going to by default inherit the player start from the default parent level object but let's go into our player object and do exactly what I just said we were going to do. We do want to keep our set position function and now let's create a new function called set level to self uh what variable do we want to call this we could probably just call it level yeah level is just fine and then we'll go ahead and say self dot level it's going to equal level or we've just passed in and we'll use self dot set position level dot player start x and I'm sure you know level player dot start y by default this is going to be zero and let's go back to our main function waiting at the bottom here and rather than saying player dot level is equal to current level we will run player dot set level for the current level that works okay for us and I'm trying to think if there's anything more we should change drawing works okay actually we should I should probably just just so you understand how this player start works I will create a version of it in self level dot zero one because we've actually called the super function everything is inherited but I'll just put this player 10 pixels in on the x coordinate takes 10 pixels to the right clock and everything works just fine for us we don't need to worry about any of this set message we don't need also we probably won't need the font then regardless running equals true that can stay close by logic testing nothing is in there yet update the screen and everything I think we're good let's run this code and make sure everything works just fine okay yep and yeah see my player starts right over here and uh he's a little bit smaller now we can jump down to get to this block down here works well for us and I think I didn't see my player move too far ahead let's let's put him 100 pixels in there he goes now he automatically starts over at this this side over cool that works just fine for us so there we go just some simple small changes um keeps it easy and actually you now have a specific position where the player will start once the level begins and you can you can modify that within each level you can change it to be whatever you want cool thanks for watching guys hope you're enjoying the series so far we're gonna get into something cool in the next tutorial and uh you can be excited for that one I'll see you soon bye