GameMaker Studio 2: Your First Game (DnD) - Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everybody I'm Sean and throughout these tutorials I'm going to be showing you how to build your very first video game in game maker studio two this time around we're not going to write any code and we're just going to use the built-in drag-and-drop interface for all of our game logic by the end hopefully our game will look something like this okay simple top-down action game with a few enemies to shoot at explode little player shoots bullets around or very cool let's get start first of all by looking at how to just put our player on the screen and move them around so this is what an empty project looks like inside game maker so you can see all of the different resources in your project over on the right and the resource tree and any resources you have open for editing will be here and what's called the workspace the very first thing we're going to want to do is part of this tutorial is create a sprite okay that's going to be an image for our player character so I'm going to right click in sprites in the resource tree and hit create okay and you can see that opens up in the workspace we can move around the workspace just by sort of clicking and dragging with the middle mouse button you can also zoom in and out with control in the mouse wheel and do various other things so now we have the sprite open we're going to do a special call it SPR and score player okay and that's just to identify that it's a sprite and that it's our player you can name it whatever you like really but I advise sticking to a naming conventions such as this the reasons that will become clear the more we develop the project so as you can see at the moment this image is just totally blank so let's go ahead and import our player sprite and click import if you're following along on YouTube all of the resources I'm using will be available linked in the description for you to download if you're following along through the IDE tutorial then just by clicking import the tutorial should bring you automatically to the correct folder where I've got all of these you don't have to use these sir these images um you can use whatever images you like but these are the ones I'm going to be using throughout this tutorial so I'm going to bring in SPR underscore player okay let's little UFO thing so that's our player sprite and over here where it says origin 0 ZZ the little crosshair in the top left of the image just right there if you click anywhere on the image with the left mouse button you can place it determines kind of the center point of your image okay so I'm going to place that directly in center of this image middle Center it also determines like when you rotate the image like with like where it's anchored like what point it rotates around okay so that's why we want this in the center very important okay so now we have the sprite the next thing we want to do is create an object so an object can be thought of as kind of a blueprint for logic interactivity and behaviors in your game okay our player is going to want to have an object representing it our enemies when we come to create them they'll have objects for them so we'll our bullets and so on the reason I say it's a blueprint is because the object can be for others defining the logic and the behavior and so on of a particular game element and then when you actually put those objects into your rooms as we'll come to later and into your game world you're not actually putting the object that you're putting instances or copies of that original blueprint there okay which we refer to in game maker as an instance of an object okay you'll be able to see what I mean by that and then it ok so right click in objects now and hit create and you'll see that it creates a new object in our workspace so this object is going to represent our player ok so I'm going to name it in the very similar to the way I need to play a sprite in the name is obj underscore player ok just as a simple way to define that that's the player sprite and that's this is the player object ok don't want to both call them both player that would lead to all sorts of problems so first thing I want to do with this object is change its sprite so currently it's not gossip right associated with it so I'm going to associate it with the sprite we just created our player sprite ok so when an instance of this object is in the game world it will appear with that sprite so over here in this event box is where I'll actually put all the the logic and interactivity in the game ok we'll define events and say when this happens do this and so on but let's just see what the game actually looks like running so if we go to rooms in your resource tree you'll notice that game maker creates a room for you by default whenever you make a new project ok it's called room 0 and that's because game maker a game maker game always needs to have at least one room order to be able to actually run okay and you see at the moment is just a big blank empty space okay this grid is just placed there by the editor you can turn that on or off so let's drag in our player object to them we'll just click and drag and bring him into the room okay scene he's there you can put them anywhere I can I can actually double click on him and click Edit and I can actually edit that object inside the remittitur if I need to but there that's a copy you see if I double click that as instance and say so this is an instance of obj underscore player now I can edit the original object and that's the original object blueprint you can kind of see what I mean now that defines this instance okay because we can put multiple copies of this into the room let's delete those now okay so let's just run this and see what we have so far you'll see it compiles at the bottom here and then boom here is our game and window it's not very exciting at the moment it's just a big blank rectangle with a little player in the middle okay so what we're going to do is make it so this player can move around with the arrow keys and will also face towards sort of the mouse cursor just sort of basic movement controls is what we're going to cover here okay so let's come back to our player objects by double clicking I'll bring this back to this workspace we enclose down the room edit X we don't need that right now and it's time to actually add our first piece of game logic okay so click add event you can see a look bunch of different events here and a lot of them are just things that happen in the game okay that's what an event is that's a when this happens something in the game has happened like a frame of the game has passed you've pressed a certain key you've clicked on this instance you've you know this instance collided with another instance and so on and so forth what we're going to do is add the keydown event or right okay so for our right arrow key that's what that represents and you can see this pops up a code editor okay so events are when this happens and code and actions are do this okay so when these things happen do these things and that's fundamentally how object logic in game maker works even when you're working with so what do we want to happen when the right arrow key is pressed well we want to move our object to the right okay and now what we're going to do is use an action to do that so scroll down this list of actions over here in the toolbox over to where it says movement and find this little icon here jump to point and jump to the specified position so we're going to move our instance from the place it is now to a different place let's just click and drag that into this box and you can see over here we have a summary of all the actions we've placed in this event and here is where we can edit what they do just use the middle mouse button - to move around just as you can with most of the rest of the interface okay and so it needs to coordinates from is that we want to move to an x coordinate and y coordinate so X 0 and y 0 is the top left of your your game room okay if I just go to the room editor this is 0 0 okay and as we increase our x coordinate we move further and further to the right and which we increase our y coordinate we move further and further down ok and if we decrease those we go the other way let's go back here so what we want to do is just increase our x coordinate to move to the right ok so I'm going to change this to 4 and I'm going to tick these boxes here that say is relative because we don't just want to move to X for y 0 that would put AZ like somewhere around here just a like 4 pixels 4 pixels to the right and 0 pixels down in the game room where as we're starting here so we want to move relative to where we currently are so by taking these we add 4 and add 0 to our x and y coordinate respectively okay so let's run the game and just see that working ok so now we have this again we just have a big black box in our player but if I press the right arrow key a player actually moves to the right now ok now we just need to do the exact same thing for our different ah different buttons ok so I'm going to add an event four key down left I'm going to drag in the same just to the recently used box up here jump to point action ok I'm going to take both that is relative boxes again very important to remember to do that and this time we're going to move -4 okay so I'm going to subtract 4 from our x-coordinate and move left okay so let's see that working just run that real quick so I move to the right and if we press left I move to the left excellent okay now let's add up and down and stick down the exact same way so key down up dragon jump the point and this time take both these boxes this time we want to move up so we want to reduce our y-coordinate so put -4 in there okay and let's just add on down event as well and do the same thing so it's relative this time increased by 4 okay so you know see now we just go through those we have four of this action all just doing different things to our corner so let's just run that now and obviously like on a given frame if we're holding up and we're holding right then it's going to both add four to our X and subtract 4 from our Y meaning we can move diagonally okay as I can demonstrate by holding up on the left but I can move in any direction now or any of the eight directions allowed to is by our by our arrow keys I suppose and that's the basics of just moving around so the last thing we're going to do is make it so our player object actually rotates to face wherever our mouse cursor is because that'll be kind of like a cross error direction that we want to shoot later we'll shoot with the mouse button okay so we want to make our player always face towards the mouse okay even though we can move around sort of strafe with our arrow keys so let's add another event this time we're going to add the step event okay you see the little footprints and there's three of these step begins step in and step we just want the regular step event so click that the step depends very special event it happens every single frame of the game that passes okay so if your game is running at 60 frames a second this will happen sixty times every second okay whatever whatever logic you put in here now what we want to happen is every frame of the game we want to check where our mouse button is where our mouse cursor is sorry adjust our objects direction to face it and then adjust the sprite to rotate to face their face the mouse okay so what we're going to do is I'm going to scroll down to movement again and find this is sort of a dotted arrow with a dot on a set point direction okay sets of direction towards a specified point so I'm going to drag this in and you see it asks us to provide an x and a y corn again we don't want the relative box at this time but if I type mouse into X here you can see and then you pops up because Gamemakers Chinese guess what we want from it we can type more than as you can see we can type more than just numbers into x and y okay we can provide what's called variables and functions which are basically words the words or commands the game maker that will turn into numbers okay for this what we want is mouse X which is a built-in variable click that and what this word means what Mouse underscore X means is it's just a word in game maker that every single frame will track the x-coordinate of our mouse cursor okay in the game and we do the exact same thing for y I'm scared type in it Mouse underscore Y okay now basically what that means is our mouse is always going to our objects always going to have the direction facing towards wherever our mouths coordinate is on the screen now that won't actually be enough to do what we want that'll set our direction for the object for the instance sorry but it won't actually change the way the sprite looks okay because those two things are independent of each other you can have an instance direction but you can also have an image angle kind of thing okay so like the sprites direction which way the image is facing because you might not always want to change the the image direction to face where the instance is facing because you can also do things like create use your direction to create speed and someone simple if you can do other things with your instance direction so what we want to do is just change the instance rotation okay so the image rotation so I'm gonna scroll down - if I remember where it is our instances of course yet so set instance rotation to see the this little pack command image is often representing things you can do with the sprite this one with a little arrow going around the outside that's instance rotation so drag this in and so to set the instance rotation now what we want to do is after we've set our direction to that okay that's what that's done is adjusted a variable inside this instance called direction okay and it's set that direction to be facing towards on Mouse so all we actually have to do in here instead of providing it an exact angle we just type the word direction and that's a built-in variable and it's one we've just adjusted through this okay so by setting that it'll make our actual image face towards the mouth and that angles around wherever you place the origin on the sprite which is why I replaced it in the center before so if I run the game now what we should hopefully find is yep our player now faces directly towards wherever our mouse cursor is on the screen so I can move around any direction and move the mouse around and the player will always face that direction okay so there you go that's the sort of basic movement we were going for and in this part of the tutorial and yeah I hope you've enjoyed that and I'll catch you guys next time while we'll be creating some Bulleit objects for us to actually shoot okay see you then thanks guys
Info
Channel: GameMaker
Views: 355,008
Rating: undefined out of 5
Keywords: YoYo, Games, YoYo Games, GameMaker, Game Maker: Studio, GameMaker: Studio, game, maker
Id: IWXJbUHLYXA
Channel Id: undefined
Length: 14min 48sec (888 seconds)
Published: Wed Nov 02 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.