GameMaker: Studio Tutorial - HUD Bars

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey everyone welcome back to a brand new game maker tutorial and today we're gonna be looking at HUD bars inside a game maker that you guys can use in your game and we're gonna be looking at stamina hot bar and a health hut bar and if you guys watch my Styles tutorial I'm gonna be using some of the aspects from that to doing the tutorial today but I'm also going to be adding in a health bar that you guys can use so the only thing that I sell is that I have the stamina bar so I have a front bar and I have a back bar and then I have a health bar of a front and a back so you guys can just set these up but make sure that they are like tight into fitting into the sprite format so it's fitting completely into the image and I also just have a 32 by 32 red box for our player and the first thing we're going to do is we're going to create a player object you guys might already have one bunch gonna quickly set one up just in case you don't so you can copy it swim do we're gonna set up oh that's not want to open we're gonna stop the initial variables so global thought stamina is a hundred global dot stamina Max is a hundred as well and then when do global dot P health because you can't do health because it's a saved variable inside game maker so you have to name it something else are just going to be short for player and that's gonna be equal to 100 or indeed global dot play global thought P health max does equal 200 as well and we're also going to implement the sprint system as well as I use in the last tutorial so the HUD works properly so movespeed is 1.8 walk speed is 1 point a and then sprint speed is equal to 4 so there's everything you did in the create event for the player and then we're gonna go into the step event for the player and I'm just gonna copy and paste this bit of code here which is basically just gonna set up the keys so that's it there that's everything they need step for the keys the damage isn't necessary but it's just so I can show you that the health is working if you guys watch my last tour you already know that I like self sure we kind of key variables to make it easier to call them when we're actually doing the move system so if key up why why - equals move speed and we'll close that off and we're going to copy this four times and that's gonna be key down I'm gonna be key left and this is gonna be key right so we're gonna change key down to plus mid speed and then key left X + X - that's fine and then the key right is gonna be X plus mid speeds so that is everything for making the player move around and the map and then we also need to set up if the damage so this is this isn't necessary like I said earlier but it's just going to show you guys this working global up he health - equals five and then I'm just gonna quickly copy the Sprint code from the last tutorial so we'll do this for sprinting so this is oh I shoulda enlarged the code for you guys a little bit so this is the sprinting system so if Keith Brennan and novelist anima is more than zero it's gonna take away the stamina and the movies gonna kill the sprint speed and else if we don't have any stamina it's just gonna be the walk speed and then if we're not using the sprint it's gonna start adding global stamina so then we can use again after a recharges we're gonna set up some equal block stamina is more than 100 global stamina is equal to V is equal to 100 just so we don't go over it and it ruins the hut I'm gonna do the same F global stamina is lower than 0 global or stamina equals 0 and then we're also gonna set up in case the player runs out of HP so if global rocky health is more than a hundred robo-doggie health equals 100 and then if global Global P health is lower than or equal to zero game underscore restart just so we restart the game so I don't have to keep closing and opening for you guys that is everything yourself if you guys don't already have a like a player system set up so that is absolutely everything and then we're gonna create we're gonna name this if I can get back to here will be J underscore player we're gonna assign little small players right to that and then the main thing for this tutorial is the HUD so we're in Adobe James for HUD the only event we need is the draw GUI or basically gonna set this up so if instance underscore exists will be j underscore player draw underscore sprites and I'm going to SPR underscore stamina back comma 1 comma a comma 6 to 4 and then draw underscores bright external this is gonna be on the front no underscore next the same in the front is going to be s PR square stamina a front comma 1 comma 8 from 64 so it's drawing on top of each other and then believe that opened didn't like comma max0 come global stamina slash the global dog Stan stamina max and close that comma 1 comma 0 come a C on comma C underscore white and then we close that and that is to display the stamina bar we're just gonna copy this I think that should work I don't know why it's coming up with that if off because I need to put a bracket there don't forget your brackets guys I'm really bad I forget in the brackets and you guys should be okay why yeah and then that closes that I'm not that was that in there I don't understand why that's not working because we need to comma one and that should be everything for that one and then we're gonna copy this we're going to do it again go into this one for SP arm score health front no sorry health back and then this one there's gonna be health from I'm gonna change this one to P health and this one is going to be P P health max by office need to change the coordinates on this one so this is going to be one a this one's gonna be one a nine nine and I think if we put this into it I just made a 1280 room with a green background if I put that and and I've heard that in as well and launch the game we should have a hut and there we go with that as a HUD so free sprint it goes down and then slowly goes back up and if I spray a space you can see that we're losing health on the HUD bar and if I feel lose health the game three stars and if you guys want to be extra we can also add in draw Russia will create we have a font we already have a phone setup it's just the built tiling phone on twelve with a with anti-aliasing on and we're going to draw underscore set bond F underscore main so we're setting the font to the one we just created underscore exists over James core player close that again it's gonna be draw underscore stands for color make color RGB so we're using an RGB scale instead of just doing C Y or see that so these colors already predetermined because I searched them up and they match the health bar and then I'm going to draw i'm score text do you underst so the x-axis because they changed it and game maker studio to it's gonna be three seven five and view underscore why pork is gonna be 0 plus 22 and then I'm gonna do string and just bring this up a string underscore hash to new line that's going to be string I don't know one global dog the health plus and then we're gonna be like a slash and then plus another string global dot key health key health Max and I'm gonna close that three times and then put that there and then I'm gonna come back and then close it and that should be everything you need to display basically the text number of how much health care and how much Mac self we have and these coordinates already predetermined because I did this just to make sure they would sit right beside it if we open up the game you can see that we have a hundred by a hundred there so if we take away it's doing the same thing there and you guys can also copy and paste this and set up for the stamina one as well but yeah that's just basically hot bars and gimmick too so again guys if you enjoyed today's tutorial make sure to go and drop a like and also subscribe and also comment if you want to see anything in particular if there's any way I could change this type of video or do something else more interesting without further ado thank you so much for watching today's video and I will see you the next one bye bye
Info
Channel: GM Guru
Views: 3,262
Rating: undefined out of 5
Keywords: GameMaker: Studio, GameMaker: Studio 2, game maker, game, maker, game dev log, development log, gamemaker hud tutorial, gamemaker hud bars, heartbeast, shaun spaulding, rm2kdev, tutorial, GameMaker Tutorial, GMS2, GMS, Game Development, Tutorial Series, Making Games, How to make a game, Game Maker (Video Game Engine), GameMake Healthbar, GameMaker GUI, Heads Up Display
Id: BiRI-8Xnjh4
Channel Id: undefined
Length: 10min 24sec (624 seconds)
Published: Fri Jan 11 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.