[Gamemaker Studio 2] Turned Based RPG Tutorial Part 2: 8 Directional Sprites

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone this is sniper ninja and welcome back to my turn based RPG tutorial in game maker studio 2 in this part you'll be implementing a directional sprite and on that note let's begin the first thing we are going to do is add in the a directional sprites if you go to sniper ninja 5 6 4 HIO slash RPG assets you will find all the assets for this project after downloading it you have to extract it in your downloads I recommend creating a folder in the folder of your game and name it assets now back to game maker studio 2 we are going to create a new folder in the sprites section and we are going to name this player now one thing I want to do is go over to my masks right and actually set the center to mid to top center now we will create a sprite and we will name this SBR player right edit the image and now go to import strip image now go to your BBQ video RPG tutorial assets and now select player right wants to do is set the frame wrist set the frame width 216 and the frame height to 24 and the phrase for row and numbers for frame 2 for now as you can see that's kind of fast as you can see we have a we have a full working animation now make sure the speeds still 15 if you don't have it on 15 it'll mess up a couple things or at least here you okay so one thing I forgot to do Center my sprites this is important make sure you do that now we need to add in one more sprite and that is the shadow SBR player shadow edit the image import strip image and I'll find the file named player shadow now set this to fit sixteen five and four now for the now for the player shadow we want to set this to eight and negative eight just like that alright we are now finally done with importing the stripes now we begin with the code the code in this part won't be as complex as the first part first off go to object layer and go to the create event we want to create a new set of variables for right barri levels are a new one game face and set it to zero once you are done we are going to create some macros to store the sprite indexes of our sprites inside a macro in game maker is the same thing as a constant it is a value that cannot be changed it is basically the same thing as a read only variable now let's create the macros you do you create a macro by stating macro now I make the macro name and what we are setting this to SBR player player player right Rx filling that wrong 10 times so what this does is that instead of else gives you this nice red color instead of having a write down SBR player player right and common spelling it wrong instead we can just put in write in all caps and I'll just basically me the same thing the reason why I put write in all caps is because we want to make sure that we don't create a variable name to write that isn't in all caps now we have to do the same with all the other ones now macros in game maker studio one work a little bit differently to create a macro you need to go the macros folder and open the default configuration now you need to write the macro name and the value in the table once you are done with that click the Add button to create another macro our player right XP our player up right alright now we are going to create a new script and we are going to name this get things script what guest face is going to do is that that face is going to divide the der variable and set the face variable to that value so we can set our sprite that way to do that we need to add this code face equals round curve divided by 45 this face equals 8 face equals 0 all right we are now done with that before we go to the move state just go and make sure you set your player sprite to SBR player right now go to move state and we are going to add the code that will animate our right and change it first first off ad get face to the length code like this yeah say so that way it only checks our face if we are moving so that way we don't need to change directions and other unnecessary code now you know the bottom of our script we are going to set the image fee to 0.5 and if we are not moving we will set the image index to 0 right image speed equals 0.5 if length equals 0 then our image index will equal 0 now finally for the last piece of code and the most complex part of code we will need to add in a switch statement that will check which sprite we need to change too because we're going to be checking multiple multiple directions we're going to do this by using a switch statement so we are switching face now what the switch statement does is that it lets you check multiple values in a variable in a way much more efficient than using else if so case equals 0 or sorry case 0 : sprite and x equals right break and break basically stops in case 1 stripe index equals up right you all right that was quite a large amount of code but that should do it now when you run your game you see that we now have fully working eight directionally player sprites now that looks great but we can do better so now go back to your player and now create a dry event what we're going to do is we are going to add in that shadow we added in a little bit ago draw layer and shadow now in a draw event everything is drawn in an order so we want to draw the the shadow first draw light svr player shadow image index so that way the shadow animates along with us x and y so that way the shadow also follows now due to a trolly fund it will basically a player is automatically drawn and you don't have to define a draw event but if you do define a Travan you have to draw the player sprite self withdraw self now run your game one more time and I can see this now looks way better there's now a lot more like to our game and yeah thank you very much for watching this video if you like this video please like subscribe and share and also check out my other social media in the next part we are going to set up the auto dialer and add foliage to our game see you next time bye
Info
Channel: Aidan
Views: 48,404
Rating: undefined out of 5
Keywords: Games, RPG, Tutorial, Programming
Id: TmeS62qX4PM
Channel Id: undefined
Length: 11min 7sec (667 seconds)
Published: Fri Jul 07 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.