Gamemaker DND Platformer Tutorial - #11 Juice

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
if you're interested in making a detailed platformer just like this one with in game maker using drag-and-drop then keep watching good a gamers and welcome back to our drag-and-drop platformer series in the previous tutorial we added a way for the player to take damage from the enemy and our game is really starting to take shape one of the things that makes a game feel good is what we refer to as juice now juice is how the game feels and how it looks and just the feeling you get from the experience you have with it now in order to give our game some more juice today we're going to add a dust effect and that looks like this when we jump we get some dust and when we land and just as generative as well now when we move and we jump and land the dust has a horizontal move as well and also it just gives it a little bit of a better feel now the other effect that we're going to add is when we jump on the enemy we get that little explosion happening just to show the impact so let's get started so the first thing you want to do is go down to the description and download the resources folder and inside you'll find a dust TIFF file let's drag that in now this is two frames or two sub images and we will just select one so that we get some variety in our dust I'm going to set the speed to zero and we're going to set the middle center as the origin now let's close that down and let's create an object it's going to be called O underscore dust and let's make sure we assign the sprite and let's add a create event now if you remember the dust it faded out and it also shrunk in size so they're the two things we want to control in the object so let's show you across an assigned variable and we're going to assign a variable to control the Alpha now an object has a variable called image alpha and that controls how I baked the object is an image alpha goes from zero to one with zero being completely invisible so we want to decrease that image alpha value over time and it'll make it look like the object is fading out so I'm going to create a variable called alpha decrease or alpha Dec and I'm going to set it to minus 0.03 and that is how much we will decrease the Alpha per step now the object also scaled down over time so let's have a scale underscore decrease or DC and I'm going to use a function here to set it between two variables I'm going to use random underscore range and I'm going to set it between the lower range of minus 0.02 , up to minus 0.001 now it's not a big range but doing that will give some variety between the various instances of dusts now we want to control the scale when the objects start so they all don't start at the same scale now an object has vertical and horizontal scale so let's set a temporary variable a now to call its scale and we're going to set a random value here too so random underscore range and it's going to be between 0.5 and 1 now the reason we do it that way is we want the scale to be the same amount for the vertical scale and the horizontal scale so now we can go here and we can set our horizontal scale and we'll set it to scale and we want to also set the vertical scale and we're going to set that to scale so that'll keep the object in proportion now I want to also do something else I want to control which frame is chosen remember there are two frames for this sprite so let's add another one and we're going to choose a different image index indexes which frame is chosen so we wanted to have it either 0 or 1 so if you've got two values you want to choose between you can do that a few ways you can use the function choose and you type 0 comma 1 and that will work you can also use the choose code block so you could drag that down here and I could set option 1 Oh 0 and another option to be 1 and we can target the value of image index directly image underscore index so that is the same as what's happening here you can also set it to a temporary variable and then assign it to image index this way obviously you need this above to do that so there's lots of ways to do it lastly you can also say I random 1 and that's probably the simplest way to do it i random will choose an integer value and when you use random or I random it'll go from 0 up to the value that you've chosen so I random will now let us choose 0 or 1 and lastly I'm going to rotate the image so let's go look at image rotation and let's set that between a random value up to 360 so now that we've set our variables we need to decrease them over time so let's add a step event and as you know that will run every step of the game now first let's go and set how horizontal scale and we want to decrease it by our variables that we created which are scale to crease and make sure you tick relative so that it decreases it by this amount per step so let's just click the plus and do the same for the vertical scale so that's going to be by scale to crease and that's going to be relative so we also need to decrease our alpha to make it fade out so let's click the plus go down to image alpha and we want to decrease it by alpha decrease and that is once again relative now image alpha will only let us see the object when it's above zero so when it gets below zero we need to destroy the instance you have to clean up and make sure you destroy instances when they leave the room or when there not used anymore otherwise you'll have a problem with your resources now we can do this a few ways we can go and get the instance variable of committee alpha and we can set it to a temporary variable say I a temp and then we can check if ia is less than or equal to 0 and if it is we can destroy the instance so that's one way of doing it image alpha is also known as image underscore alpha and there it is there so doing it this way you don't actually need this check we're just checking the image alpha directly some people prefer to do it that way some actually prefer to leave this get instance and then check it this way look I'm happy for you to do it either way you want to do I actually am more comfortable with typing it out because it does help you prepare or GML maybe later on so I'm going to remove this and I'm just going to check it directly so now that we've created the dust and we have a way for it to be destroyed we need to create it in the game so if we go look at our player and we go to our step event in the air is where we want to create it so when we land we create a dusty instance at that point so in the air state after we've checked the ground and we've checked our state we can then do another check here and say if we are on the ground then we can create the dust so let's drag across an air variable check just place it under a check state and we're checking for on underscore ground which if you recall is a variable that we set when we are on the ground so if that is equal to true then we want to create the dust now because we're going to create the dust when we land and when we jump I want I don't want to do it twice so we will put it inside a script so let's go execute script and the scripts going to be called SCR underscore create underscore dust so I'm going to take a copy of that and the reason I didn't just call it create dust is because I might want to use that as a variable later on and you can't have a variable the same name as a script so let's right click on scripts say create paste that in and now we can create our script now I don't just want to create one dust item I want to create a few so we can use the repeat function so if you type repeat there is a loop there and repeat we'll do something inside the code here however many times you nominate so let's set it to I random and the score range between three and six so I will do an integer remember so it will be over three four five or six so let's click declare a variable of where we want to create it now I'm going to set a temporary variable of X X I'm going to set it to random range between minus 20 and 20 so this will let us create it anywhere from the X of the player 20 this way and 20 this way now let's do the same let's declare a Y so the Y between random range of say minus 10 and 5 so we're creating a rectangle where it'll be created within that area somewhere now let's create the instance and the object we're creating is a dust now we're creating it at our X X but make sure it is relative because it's X plus this and then for our Y I'm going to create it at V box bottom which is the bottom of the players mask and then we want to say plus y Y so we'll add this on to the value of the bottom of the mask it is not relative because this value just like Y is a number in the room now for the layer I'm going to create a special layer called dust so let's go create that now so just above player I'm going to add a new layer press click on it and press f2 and call it dust now we also want to create it when we actually do the jump and not just when we land so let's go into our check jump script and after we have created our jump we can drag across an execute script and all we have to do is select the script we made and the dust will be created that's a great thing about adding it to a script we can reuse it so let's press play and let's have a look at our dust so now when we land we generate dust and when we jump we get some dust as well great that's looking really good now one thing is when we are moving and we make a jump the dust just sort of sits there it doesn't really have any personality it just doesn't follow us or do anything so I would like to add some horizontal movement when we make a jump if we're moving so let's close that down let's go to a dust object and let's create a variable and I'm going to call this dust HSP initial so the dust horizontal speed initial I'm just going to set to 0.5 now let's go into our script for creating it now when the play is standing still we don't want to create dust only when we have horizontal movement and the direction we want it to move is the direction the players going and remember the player has a facing variable so we can use that to know which way the player is moving now after you created the dust we can take this temporary variable and I'm going to give it a target of I NS T so what that means is once we create this instance the ID is stored in this variable and we can use it to access that instance and change things just for that instance now this was really powerful and something that you should use a lot because it's very handy so let's do a check here after I've created it and remember we're running this script from within the player so we can look at the players HSB their horizontal speed we can say if that is not equal to 0 that means the player is moving and if they are moving we want to take the position or the direction they're moving and give it to the dust so we're going to assign a variable now we want to change the horizontal speed of the instance that's created and that is the inst we can access the in spice aying ans T dot and then anything we type after this will be referring to this instance because we call it that name now objects have built-in speed variables they are called H speed and V speed horizontal speed and vertical speed now Gamemakers objects have H speed and V speed built into them and if they are set to values the object will move at that speed per step so there's no way to stop them moving unless you set the hp/lb speed to zero and that's why I don't use them for our movement we want to control it better so we use our created HSP and our VSP variables instead but it's good to know that an object can be controlled with these variables as well so I'm going to set the nth speed variable and I'm going to set it to the variable we created which was dust underscore HSP initial now remember this variable was created inside the dust object so we also need an in steel because this variable belongs to the dust object now I'm going to times it by the facing direction which is the facing direction of the player and that will enable it then to move the direction the player is moving now this is quite complicated I'm not saying this is an easy thing to remember but I'll make sure I drag that up here as well what we want to make sure we're doing is understanding what's happening here now this is a little bit complicated you can do it another way you can use the apply too so if I just go here and I apply it to I type in expression of inst so now we're now applying things to the inst object and we can go and do it or used to which is setting instance variables so we can go down here and we can set our horizontal speed to be dust underscore HSP initial times facing now remember we are inside the dust object when we're down here so facing belongs to the player not the dust object so we'd need to type other dot facing and when you're using and apply to other will refer to the object that's running it so the concept is a little bit complicated I hope you understand how what I'm saying here and well how it works but you can do it with this method or you can do it with this single line either one would do the same thing so this one here or this will do the same thing but understanding how it works is actually really important so I'm going to close this one I'm just going to use this where I'm setting the HSB directly and I'm setting it to the dusts dust HSP initial variable and the facing of the player so let's test that out so now when we jump you see our dust moves in the direction that the player is moving and it just makes it feel a little bit more alive so the other thing you can do is slow it down over time so let's go back to our dust object had another variable and I'm going to call this dust under school slow down I'm going to set it to 0.99 now in a step event let's slow it down using that so go in here and we'll say that if our H speed sorry if our horizontal speed is not equal to zero then we want to slow down so I'm going to drag across a set instance variable and I'm going to set the horizontal speed to be whatever our H speed is times by that does slow down variable so what that means is we're taking we're getting basically 99% of whatever Hayter speed is because we set it to 0.99 just here we're taking 99% of our H speed per step so it's slowing down over time so let's have a quick look so now it's very minor you can change that if you want it to slow down more but it just makes it not follow at the players speed of one it's just a little bit more subtle so let's now add the vertical dust so back we're create a dust let's now do the same for our vertical speed so that when we jump we give our dust a little bit of elevation so we're doing the same check here we're saying if our VSP of our player is less than zero and what that means is less than zero if you remember means we're moving up so if it's less than zero we are moving up we're jumping in that case we want to assign a variable I'm going to take a copy of this one and paste it here and make sure it's under there and we're just changing our V speed and our dust the speed initial now for the V speed you've got to make sure we remove the facing because we don't want to times by facing we're always going to be moving up and we need to set this dusted espy initial so let's go to our dusts object let's create the variable I'm going to call it dust VSB initial now we need to set it at a negative value so negative 0.05 because negative will mean it's moving up so we need to slow down that vertical speed over time just like we did with the horizontal so just here we want to add a check and we say if our V speed is not equal to zero then we can take a copy of this instance variable check paste it here and we want to check our vertical speed and we want to slow our this piece be down by dust slow down so let's play that so now we should have our game running with all our dust effects in action so when we jump we get our dust rising if we stand still and jump it rises and this way as well and also we get that nice horizontal movement with a little bit of a slowdown so when you jump you really notice it's slowed down a bit you can change that 0.99 to something less and you'll get more dust slowdown that's up to you now the next thing I wanted to add was that jump on head effect so let's drag in the sprite for that so the sprite is just our explode ring I'm going to drag that in and we want to center the origin on this one so let's go and create an object I'm just going to call it o underscore explode ring let's assign the sprite and add a create event now this is working the same as what we did with the dust we set a horizontal scale we increase it we decrease the Alpha so it fades out so it's all going to be very familiar so let's add our horizontal scale change we're going to add a temporary variable I'm going to call it scale and we're going to set it to 0.01 then we're going to set our horizontal scale to be a your scale and also our vertical scale to be the value of scale now you could have just entered this here and here but if you're doing this for a lot of variables now we just change this and it changes for both of them so it's sort of a better way to do it now let's also assign some variables for our alpha so we're going to have our alpha decrease and I'm going to set it at minus 0.1 now for this one we want to increase the scale so I'm just going to call it scale increase so we know that that's the way it's going and I'm going to call it 0.05 and it's a value so let's add a step event now and let's set our instance variable of our horizontal scale to be that scale value increase and we're going to do it relatively to make sure that it grows over time so let's add the vertical as well and that's going to be scale increase make sure you check relative and lastly we want to change the Alpha so let's go down to our image alpha and let's make that alpha decrease and make sure you click relative now we need to destroy this object when the alpha is below zero just like we did with the other one so let's do a check here and we'll say if our image underscore alpha is less than or equal to zero then we want to destroy the object now we need to go and create the object so let's go into our player and the collision with the enemy so in here's where we can create it because we know that is where we jump on the enemy's head let's go up here and right here we're applying variables to the enemy let's create our instance here and the reason I want to do it here is I want to use the B box top of the enemy to create the effect at so we're going to create our re explode it's going to be zero relative for our X but it's going to be B box top for our Y and I'm going to create another layer here it's going to be called FX and let's just go and create that above the player so we can use this for various effects that we want to show I also drag that above the dust all right so let's press play and see what that looks like so now when we jump on enemy's head we get a nice little effect and we get our dust as well so it's just adding so much more to the game now that's looking great if you've enjoyed this remember I have a udemy course which is based on GML but it's about making a tile based platformer and it has a lot of effects and graphics and you learn how to put a menu in and a high score and a lot of other things that are basically making it a complete game you can check out the link of the description there's a special coupon code it gives you over 90% off currently that course is the highest rated game make a 2 course on udemy so check it out it might be something you're interested in so thanks for joining me I'll talk to you next time [Music]
Info
Channel: Slyddar
Views: 6,602
Rating: undefined out of 5
Keywords: gamemaker, drag and drop, dnd, collision, platformer, platform, make game, jump on head, enemy ai, gms2, drag n drop, drag, drop, dragndrop, tutorial, peter morgan, one way, oneway, fall, make games, shaun spalding, heartbeast, spalding, yoyo, gms, advanced, learn, vertical, parallax background, parallax, enemy, damage, kill, hurt, mario, jump, damage player, dead state, dust, fx, effects, juice
Id: PCXaj4ldRSo
Channel Id: undefined
Length: 23min 54sec (1434 seconds)
Published: Thu Jul 18 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.