Gamemaker Studio 2 Locked Doors and Switches

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome to today's tutorial my name is joseph in today's video i'll be covering a extension of the um dynamic door saving and game slash the doors and rooms tutorial i did the other week in this tutorial i'm actually going to be tackling um how to open a locked door with a switch and how to do it at extended range and stuff like that and how to make it a bit dynamic before i get into it i just want to say a big thank you to everyone on the channel you guys are all amazing keep doing what you're doing join the discord if you're interested and i shall get into the tutorial so i'm going to load it up and show you guys how it works so once i load it up you can see here i've got pretty much same stuff as before the only thing that should be different is you can see i can't open the store anymore and you'll see that it's still saving if i go down to the switch though and click on it you can see i can open and close the door so you might be asking how am i actually achieving this and the rest of the game pretty much saves except the switch because i haven't embedded the saving function into it so the way that works i'm actually controlling some of the values in this door with this switch by using an extension so let's get into seeing how that looks first things first i will highlight my switch is only 20 by 40 and i've centered it so it's a bit different from the usual stuff i do okay so let's get into the door element first so you can see here i've actually got a locked door now instead of just a door and to be honest i've cheated a little bit normally when i would do this if i was doing something a bit more we'll call it more professional instead of dodgy is i would attach a flag or a value to say this is locked and then another one to say is there a key so then that way i could say manipulate that function which then tags everything else down or is there a key that the player can access tag all the way down again i am going to highlight very bad name there that is the actual function to open and close the door not just draw the door i've named it very poorly i'll just highlight it highlight hi like that again the other aspect here is you'll see i'm missing the click function in my door so i can't just click on the door to open it anymore the way we access the door now is through the switch here so i'm just going to run through each of the functions for the switch so the first step here is actually just set the um switch tag to see if it's active or not which is just your stock standard stuff the next two is i pull a x and y value from my room so if i load up my room the y and x values i'm pulling so if you look down here this is your coordinate value are from about there so i'm actually pulling this door's information so i'm basically taking x y and then i'm using a collision to check to see if i'm looking at the interlock door and if it is looking at the interlock door i'm storing the id inside here using this collision function then i will pass that over to the next step now let's go to the step event and i'll kind of walk you guys through what i'm doing in here so i've got a collision rectangle and i've basically centered it on my switch because it's centered i just have to account for all sides and i've added 10 pixels to most sides except the back of the switch and again i'm just looking at if the player interacts with it the next step is a pretty stock stand i'm just looking at mouse position to make sure i'm clicking on the switch than anything else and if i am i proceed to a press and i change the switch tag to true or false based on its status and then this is the part that gets a bit more interesting is i actually use the object id in here and i drag through the doors information for stat for the status of it if it's opened or closed so if i do that you can see here i'm basically pulling this id through into the switch using this dot value which basically means object id call door value set value so that's the idea there so in theory if i wanted to i could attach it to a door that you could open normally and you can attach it to a switch so you can kind of have the best best of both worlds if you really wanted to for your game the next thing i do is i just draw the sprite so again i've taken a slightly different approach to normally i'm being a bit more lazy or more efficient and you can see i've got a switch spry and i've got the actual status in here and the reason for that is false and true then i'll just quickly write this out false is equal to zero and true will be equal to one which means if i'm got a sprite index index of zero that's our starting sprite or a sprite index of one which is my activated sprite so you can see i'm just being a tad bit lazy but that's pretty much that's um or to this so i'll have this up in the google drive so you guys can access it and play around with the source code nothing else has changed other than that nice simple easy tutorial for you guys i will see you guys next time keep being awesome and i will talk to you guys later see us you
Info
Channel: Domain Studio
Views: 85
Rating: undefined out of 5
Keywords: Gamemaker, Studio, tutorial, GUI, Programing, Easy, Help, GMS, If, Pass, Through, Doors, Rooms, Locked
Id: XGNobaDIbfE
Channel Id: undefined
Length: 6min 9sec (369 seconds)
Published: Wed Jun 09 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.