How to Make an RPG in GameMaker Studio 2! (Part 1: The Basics with Player Movement and Collision)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Even if I don't watch a posted video (I am going to watch this because I want to make rpgs) I always up vote tutorial content. We need more of it, and there is no upper limit. Keep on keeping on. :D

πŸ‘οΈŽ︎ 12 πŸ‘€οΈŽ︎ u/TomMakesPodcasts πŸ“…οΈŽ︎ Apr 29 2021 πŸ—«︎ replies

Yeah only watched first few mins, but looking good.. Will be watching and working through it.. Nice work !!

πŸ‘οΈŽ︎ 10 πŸ‘€οΈŽ︎ u/TheOnlyWelshGuy πŸ“…οΈŽ︎ Apr 29 2021 πŸ—«︎ replies

Great little tutorial series! Thank you for making these. I saw the recent menu tutorial as well and am curious if you've got any additional specific tutorials planned.

P.S. Rose of Starcross looks cool

πŸ‘οΈŽ︎ 5 πŸ‘€οΈŽ︎ u/Bent-My-Wookiee πŸ“…οΈŽ︎ Apr 29 2021 πŸ—«︎ replies

Looks great! I don't think I'll be able to follow this one sadly, as I have 1.4 and not 2, but it's really great that you took the time to break this down for beginners. This is gonna be helpful for a lot of amateur devs!

πŸ‘οΈŽ︎ 4 πŸ‘€οΈŽ︎ u/EmpathyInTheory πŸ“…οΈŽ︎ Apr 30 2021 πŸ—«︎ replies

Thank you so much, it’s really coming handy, always wanted to make an rpg game

πŸ‘οΈŽ︎ 3 πŸ‘€οΈŽ︎ u/vveaboo πŸ“…οΈŽ︎ Apr 30 2021 πŸ—«︎ replies

THANK YOU, I didn't realise I needed this, so thank you

πŸ‘οΈŽ︎ 3 πŸ‘€οΈŽ︎ u/cur0024 πŸ“…οΈŽ︎ Apr 30 2021 πŸ—«︎ replies

Right on good stuff man

πŸ‘οΈŽ︎ 2 πŸ‘€οΈŽ︎ u/OfficialBradleybus πŸ“…οΈŽ︎ May 02 2021 πŸ—«︎ replies
Captions
hiya welcome to my little series here where i'm going to show you how to make the game that you see on screen right now this series is broken into six different parts and this first part actually has two different versions the version you're on right now is 100 completely beginner friendly it'll give you the basics of game maker and how programming game maker works you'll get familiarized with the fundamentals and we will get a player on screen that can walk around and run into walls i do my best to explain everything that shows up in this video as thoroughly and clearly as i can so if maybe you've poked around a game maker before maybe you've watched one of the yoyo games kind of built-in tutorials or maybe you've watched a basic tutorial for some different type of game like a platformer from someone else then you can go on over to the other version of part one which is a good bit shorter and doesn't walk through everything quite so slowly so yeah all you need to do is just download game maker studio 2 and we're off all right so uh let's just make our new project here we're going to use game maker language and then we need to name our project very cool rpg exude confidence and we're in okay so first things first on the right here we have the asset browser which is where all the assets for your game are going to be and organized uh the first thing that we're gonna do we're just gonna jump right in and we are gonna make a sprite to represent the player so we click on sprites we right click go to the create menu which brings the drop down and create a sprite asset everyone has their own kind of naming conventions for stuff uh the way i generally do it is by doing spr underscore and then whatever i want to name it so i would call this sbr underscore player you'll probably see different people do different stuff it doesn't really matter just as long as you're consistent with yourself okay so let's click down here on this first frame so we can open up the editor now the default size for sprites are generally going to be like a 64 pixels wide and 64 pixels tall see down here let's go ahead and resize this to a 16 by 16. so we can go to the top here to image and then go to resize all frames resize canvas and then 16 times 16 and apply that so good we have a good little square now we have good size square now so uh let's just fill this in with the color i'm gonna pick this beautiful red and this is our player for now and that's it that's all we gotta do here so exit out we now have this sprite asset here uh pretty cool and we really don't need to do anything else here either so it's done now sprites are just images even if they're full animations that's all they are they don't actually run any code that's all objects that actually run code and make your game a game so let's make an object for our player as well so let's right click on it the same way go to create and this time we're going to create an object now uh i named my objects obj underscore and then whatever it is i need to name it again just stay consistent with whatever it is just as long as you know what's going on that's what's important so the first thing we're going to do with our object is go into this little drop down menu for the sprites open up our sprite folder and then assign our player sprite to our player object all right cool now we have an object uh we have a player it won't do anything there's no code but we'll get to that in a second so now we can close out of this we have a sprite we have an object and the final thing we're looking at for this little basics are the rooms there should already be one here so let's open that up and this is it so this big black box is your room where you can put your different objects and stuff uh over here you have your layers instances uh are what you would also call objects so this is a layer where you can place your objects the background is currently this big square here and let's just go ahead and put our player into that instance layer so to do that you highlight the layer that you want to place things on then you go over to your resource tree highlight the thing you want to put down it has to be the correct type of asset and then as you hover over the room you can hold the alt key and then you can place an object wherever you want to um let's put it up here on the top left for a second because after we place this in well now it's in the room which is great but now that we've placed this something we need to do is we're going to resize our room it's very big right now so on the bottom left we're gonna do a couple different things so the first thing here you have the width of the room and the height of the room let's go ahead and set that to 288 wide and 216 high so now our room is a much more reasonable size compared to our player um let's continue on to viewports and cameras which is very very important this is how wide and how tall the view in pixels of your game is going to be and essentially how big the window is going to be whenever you run the game that's the viewport so let's enable our viewports we'll go to viewport zero make it visible we'll turn it on you'll see here it just appeared this border it's huge because it defaulted to the same size as the room whenever it started so for our camera we are gonna do it with those same values that we made the width and the height of the room which is 288 pixels wide and 216 pixels tall this is a 4x3 ratio you're probably going gonna either want to do a four by three ratio or a 16 by nine ratio it really doesn't matter uh i would say just go ahead and do what i'm doing here just to make it a little bit easier and i just thought this was kind of if you're wondering where these numbers came from i just thought they kind of looked cool i like this resolution but yeah so our viewport we are not going to want to make it exactly the same size as our camera because the viewport is how many pixels on our actual display the window will be taking up so if we made that 288 by 216 the size of our window would be this literal size right here which would be very very tiny so for a viewport what you're going to want to do is multiply the camera size by just some whole number uh i like to do it with this by 3 so 864 by 648 this is how it works for mine i have a 1080p monitor so if you have like a 4k monitor it's probably still going to show up really small so just know that you take these numbers and you multiply them by the same whole number to make it bigger otherwise you're going to get weird scaling and the pixels won't be the same size as each other and stuff like that so yeah okay so uh right now we can actually run the game because we've fixed our camera we've fixed the viewport and we've put an object in the room here so uh let's see what we've done not much no but seriously this is pretty cool so you you've run a game and uh you you know you did it you can't it's not fun at all because you can't do anything with it um let's rectify that right now so close out of this uh we'll go back to our workspace we can go and close out of our room we don't need it right now and let's go back to our player object so now we are going to start adding code finally i'm going to minimize that just so we have a little bit more room all right okay so we're back to player object here we have the event window and events are the actual places where code is run so let's add an event we're going to add our create event and a create event is so all of the code that we would add here will run at the moment this object is created in the game a lot of times you will use the create event to initialize your own variables and we're going to do that right now so we can get rid of this commented code we are going to make two variables that will represent the speed our player can go left and right and up and down so i'll show you what i mean so first let's call this x speed equals zero so this is how you would set a variable you type in whatever you want that variable to be equals whatever value you want it to be and then end with a semicolon a variable is just a string of letters it could be anything that you want it to be as long as it's not some built-in function or constant or whatever in game maker and it will turn blue which means that yes i initialized this i created this variable called xspeed and anytime i reference xspeed after this in my code gamemaker will know that xspeed means zero and i can also change the value of it i'll show you how this all plays in in a second so this is just know that this is just how you would set up a variable so let's set up variable y speed as well so we're going to be using these two variables to determine how fast the character will move left and right for the x value and up and down for the y value and we're going to set one more variable here and we're just going to call that move speed and we will set that to 1. okay now that we've set those up we can close our create event we're done with it for now and we can add another event and this is the step event so like i said the create event only happens at the beginning of the creation of this object it runs once it's generally for initializing things starting things up the step event runs every single frame of the game so the step event is mostly what you're going to use to actually do things in your game so let's get rid of this code and we're going to do our first function so i'm actually just going to type this out and then i'll explain how it all works so we're going to say write key equals keyboard check vk right and semicolon so as you can tell we're actually initializing another variable again uh you know what that is so i'll explain this keyboard check is a function functions are this orangy yellow and basically they return values based on what you're feeding them so what this function is doing is it's checking your keyboard for a specific button being pressed this red value here is a constant in game maker which means that it's a variable that has already been built into game maker it already has a value and this one specifically vk right represents the right arrow button on a keyboard virtual key right so this function as a whole is checking to see if the right arrow key is being pressed if it is being pressed keyboard check returns the value of 1 and if it is not being pressed it returns the value of 0 which basically means that the value of the variable right key that we created is dependent on whether or not the right arrow key is being pressed if it is right key equals one if it isn't right key equals zero so let's do this for uh the other directions really quick okay so now we have variables that hold the value for if you're pressing right left up or down on your keyboard we're going to be using this to figure out the movement of the character which direction they should be going the speed they're going all that kind of stuff you may be wondering i i said that you'll generally be initializing variables in the create event uh you can do it anywhere you can as you can tell you can do it anywhere as long as you're never referencing a variable you haven't set before you've said it because then game maker doesn't understand so it doesn't have to be in the create event generally it's a good idea to do it but this is fine right here so let's use some of the other variables that we set up with these to actually move the character so as i said before x speed is the speed at which our character moves left and right and here's how we're going to calculate that so we're going to say xspeed equals right key minus left key all right move this down a little bit so basically what this is saying is this is taking the values of the right key being pressed and the left key being pressed and it's using them in a way that should calculate the direction we're going on our xspeed so what that means is if i'm pressing the right button and not pressing the left button right is going to be 1 the left button is going to be 0 so that will be one minus zero rxspeed equals one if we're pressing the left button and not pressing the right button right key would be zero minus left key which would be one so that would equal out to negative one which means if you are adding negative one to an x value it would actually be going backwards so it'll be going left uh this also ensures that if we're pressing both the right and the left key then it'll equal out to zero and your character won't move this isn't finished though this would work how it is but we set this movement speed variable so basically what we need to do is we need to add parentheses around these two so we're taking this value that i was just talking about and then we're going to multiply it with a little star here multiply it times our move speed if you're an astute math student you'll know that this actually doesn't change anything because this value is still only being multiplied by 1. but basically what this means is setting it up this way if we wanted to change the speed our character moved at if we wanted to say our character movement speed wanted to be two then now the same code is running but it just is calculating properly how fast we want to go left and right [Music] so that's why this is set up the way it is so take this back to one because one is a nice number and we're going to do the same thing with the y speed but don't just copy and paste this uh like exactly like i'm about to do hold on um basically what we're going to do with actually no no i'm going to type it out uh so we don't get confused here so let's go ahead and add our parentheses here now uh the way y values work in game maker is actually probably the opposite of what you would expect so if you are going up this this way to the top of the screen the y values actually go down and if you are going this direction to the bottom of the screen the y values actually go up all that being said what we're going to need to do is because going to the bottom of the screen needs to be added we're going to start with down key the down key value subtracted by the up key value so if you're pressing the down button and not pressing the up button you'll get one minus zero equals one your y speed will be one so it will be going down towards the bottom of the screen so let's do the same thing here we will multiply that times our move speed okay so these are all variables that we have set ourselves it won't actually do anything uh we're just changing our own variables so now that we have determined what our x speed and y speed currently are based on what buttons are being pressed we can just add them to the built in x and y values of the objects so you see x is green there because that is a built-in variable for the objects in the game so we could have x plus equals x speed uh so this is how you would add something to a value uh this is completely identical to say doing something like x equals x plus x speed these mean exactly the same thing every step of the game this value will be added to x either of these mean the same thing this is just the more proper way to do it it's a little bit less redundant and it's just how you change values like that so let's do the same thing with y plus equals y speed so now we are determining our button presses here if a button is being pressed and which buttons are being pressed then based on those we are calculating the speeds at which it should be going left and right or up and down and then we are actually adding those new values to our object here which means that it will move around the room so we can actually just run that right now we have our room over here the player is already in here so uh we can actually go up and run our game now and have our player move around a little bit [Music] and hey look at that all right okay cool so we're not done yet we got one more thing to do and we are going to add walls for our player to run to run into you know like like a big old goofball all right so let's get out of here you know what actually before we do the uh we make the walls i want to show you let's change our uh let's change our move speed to 10 let's actually use this this bad boy let's see what that does [Music] all right that was fun anyways let's get back to the walls okay so we gotta exit out of our room we can get rid of the player object right now uh now we need to make a new sprite everything from here on is stuff that we've already done so uh just with a couple extra bells and whistles but uh let's make a new sprite done this go to right click go to create make sprite click on this first frame we'll do the same thing here that we did with the player we'll resize the frame to a 16x16 and we can make the walls this pretty blue and that's pretty uh pretty easy oh i forgot to rename it so we can exit out here we rename it right now spr underscore wall easy peasy uh let's go over one thing i didn't with the player sprite so up on the top here you can see there's this little point this shows where the origin of the sprite is they always start in the top left for new sprites you can do this drop down menu it'll uh let you change where it needs to go you can change the values manually here you can drag it around for our wall we are going to keep it in the top left but i'm going to go ahead and cover this now since it's you know it'll come into play at some point and then this bottom left menu down here is called the collision mask collision masks are what objects use to check for collisions that's that's pretty self-explanatory there are certain functions in game maker that will check if objects are colliding with each other and their mask is norm is determined by the sprite that they have so uh this one right now is the whole image there you can have it automatically generated you can make it be the full image which would be the same thing here or you can do it manually and i'll just do this just to show you that see this is how it kind of works you can move it around we want it to be the full image right now so you know we can keep everything how it would be this is just important for actually making sure that the player runs into the walls properly and we could do the same thing check the player sprite really quick it should be exactly the same it should be this whole thing if i go into manual i can see that it is this full square but just keep this in mind because down the road this is something important to note all right now let's make another object for our wall so create go down to object name this obj wall and then open our sprite folder and take the wall spray awesome thing about uh the way we're doing walls here is this wall actually doesn't have to run any code at all the interaction with the wall and the player is gonna be totally done in the player object so we're actually just just done with this so let's go back to the player into our step event because remember that runs every single frame of the game and whenever we're checking for things like collisions when the player can move and stuff we're gonna need to check it every single frame okay so we're learning a new function right now and we're gonna we're gonna put this new code right in between getting our x and y speed and actually adding our x and y speed and you'll see why that is in a second so um here's another little trick too if you put two forward slashes you can create a comment in your code which it's not code at all it's literally just something that you can use to mark stuff for yourself so we'll comment this out and we will say this is the collisions again i'm just going to type all this out and then i'll explain it step by step afterwards okay so we have a new function and our first if statement so an if statement basically just means uh whenever you write if like this and you put the some kind of conditional here it could be a function it could be a simple mathematic equation whatever it is an if statement says if this statement is true then you can execute all of this code in between the curly brackets you have to use curly brackets after a statement like this that's just how coding works you'll see this kind of thing a billion times it'll get burned into you very fast i promise so now let's let's look what this statement is actually asking for it so this function here place meeting this is checking to see if there is a collision between the object calling this function and this object over here so you can see there's three separate things here [Music] if you look on the bottom you'll see that whenever you have a function highlighted or clicked on it'll give you the little pieces that it needs to actually check to see if it's true or false or whatever these are called arguments so there are three different arguments here so here it's looking for an x position a y position and an object to check for a collision so the x and y values that we are using are going to be the x and y value of the object that's calling it so the player but we are checking the player's x value plus the x speed that we've gotten here the xspeed has not been added yet we're checking before we get to that point if there is a wall in the way then we're going to change our xspeed back to zero which means that it will not go forward anymore and it won't run into the wall and it won't get stuck in the wall so pretty simple there are a few different ways to do this actually there's a billion different ways to do anything in programming but this is just the way i like to do it so yeah pretty easy let's also do it for the y value so just make sure whenever you're doing the y value check is that you're adding the you're checking the y plus the y speed value and that you're setting the y speed value back to zero if you have some issues uh you might have accidentally put xspeed on one of these or you might have added y speed to x whatever there's a lot of things that can go wrong in programming you just kind of have to if something does go wrong you just kind of have to go back over and pay attention okay so uh now that we have this we've only got two more things to do one is opening up our room here we can go back to the instances layer because we're adding more instances now we are adding a wall so if you remember you just have to hover around here and hold alt and you can place walls so let's just place a couple around here now something you can do uh i've been i placed individual walls but what you can do is you can actually just place one and you can just drag it if you want that collision mask that we were talking about will scale with this thing right here so this is totally fine to do you can place them individually it's probably better to have less objects all over the screen or whatever but you know it doesn't really matter you're probably gonna be because it doesn't matter okay but we have the walls here so let's uh let's run the game and see if we run into everything all right [Music] all right here we hey look at that we're running into everything everything's going uh everything's going pretty smoothly pretty perfect look at that okay so first video down if you have any questions about anything there's a comment section you send me a message on twitter or i have a discord which is for my game and if you just kind of happen to find this video then yeah check out my game rosa star cross there's a free demo there's a trailer for that on this channel but uh yeah part two is going to be focused on actually getting some animations on our character which is going to be super cool like i said in the beginning this was just an alternate version of part one this video has ended in the exact same place that the other one does so you can go right into part two the pacing for the rest of the videos will be a little bit faster but now you should be well equipped to keep up with it a plus when push comes to shove it's just it's just programming you just have to copy what i do but uh yeah i guess that's it for this first one good luck and uh keep on [Music] trucking you
Info
Channel: Peyton Burnham
Views: 157,201
Rating: undefined out of 5
Keywords: gamemaker, yoyogames, rpg, how to make, how to make an rpg, gamemaker studio, gamemaker studio 2, gms, gms2, tutorial, beginner, beginner tutorial, undertale, omori, top down, pixel art, indie game, how to make a game, rose of starcross, earthbound, platformer, rpgmaker, rpg maker, pixel, from scratch, deltarune, delta rune, easy, coding, code, programming, cute, animation, player movement, collision, parallax, player, depth, tiles, tileset, tilesets, camera, room transitions, warp, rpg tutorial, nintendo
Id: KnfQo32ME5g
Channel Id: undefined
Length: 28min 50sec (1730 seconds)
Published: Thu Mar 25 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.