How to Make a Menu System (with Submenus) in GameMaker Studio 2!

Sdílet
Vložit
  • čas přidán 7. 09. 2024

Komentáře • 491

  • @peytonburnham4316
    @peytonburnham4316  Před 2 lety +29

    Check out my Patreon! www.patreon.com/peytonburnham
    Go there if you want to help me out a little more so I can make more videos like this (full turn-based RPGs, platformers, zelda-likes, beat 'em ups, etc)!
    There's a bunch of cool perks like getting videos before CZcams does, voting on future series, and getting the project files and assets from future videos! Thanks!

    • @masahiruQwQ
      @masahiruQwQ Před 2 lety

      i have a question

    • @masahiruQwQ
      @masahiruQwQ Před 2 lety

      can u explain how to make a sub menu if its option[0, 0]
      thx

    • @Axogamerlover
      @Axogamerlover Před 7 měsíci

      i cant seem to see the text in my menu

    • @superstarichiban
      @superstarichiban Před 12 dny

      Is there a way to have this menu system work with a mouse-based input?

  • @SecretEccentric
    @SecretEccentric Před 3 měsíci +9

    one of the things I love about your videos is that the comments garner such a wide range of experience from folks, every comment I see is either thanking you for the tutorials, talking about the things they made from the tutorials, or someone asking for help with something that wasn't exactly made apparent in the video and getting helpful replies from multiple people. I love it here :)

  • @SGTIvan921
    @SGTIvan921 Před 10 měsíci +17

    Timestamps for reference:
    3:50 Declaration of variables in obj_side_menu
    4:23 Array of options
    5:21 Draw the menu
    7:20 Brief demo
    7:40 Draw the options, set up font (skip to10:07 if I already have a font)
    9:27 Clean up event: font_delete the custom font.
    10:07 Draw font
    11:00 Use of for loop: draw the options if i < length of the option array
    11:46 Add padding to the text
    12:33 op_space * i will ensure that the options are not drawn on top of each other, they are drawn like a normal menu
    13:04 Demo
    13:20 pos variable in Create event - we're gonna start being able to select the options
    14:25 up and down key
    14:42 We want to prevent the pos from going above 2 or below 0.
    15:44 Changing text colour to show which one selected
    16:25 if pos == i, _c = c_yellow
    17:12 Step event: add a switch statement (for the purpose of entering the option)
    19:31 Demo
    19:45 Submenu making
    20:01 Make the option array 2-dimensional, add a variable menu_level (note to self: I could use regions as a way to open and close to see what are the options under the, say, settings menu. Here, he does it by separating the menus.)
    21:09 Create event: set op_length to 0, since we will set the option lengths dynamically in the step event.
    22:04 Change that bit of code to draw from a 2d array instead of the previous 1d array (option[menu_level, i])
    22:20 Changing up the organisation of the switch statement, and there will be another switch which checks for menu_level.
    24:20 Set menu_level back to 0 if pressing back in settings menu, and set menu_level to 1 if pressing settings menu
    25:00 Fixing the bug (the for loop) [Done by setting a local var _sml, whereby, in the switch statement of the menu_level, if it does not equal to menu_level, then set the pos = 0. This is to prevent the unexpected bug of the for loop looking for an option 3 in the main menu when there isn't one.]
    26:45 Demo
    27:24 Dynamically get width and height of menu
    27:59 An important note related to string_height
    29:34 The local variable _new_w: setting new menu width based on which option the longest
    30:31 Centralise the menu

  • @RandomGameBenchmark
    @RandomGameBenchmark Před rokem +48

    to play a sound when you change the menu lines
    create a line called
    last_selected = 0; in create event and go to step event
    now in step event, put this code there
    if (pos != last_selected) audio_play_sound(YOUR SOUND NAME, 1, false);
    last_selected = pos;
    thats all

    • @toddqdev
      @toddqdev Před rokem +1

      where to write the code?

    • @RandomGameBenchmark
      @RandomGameBenchmark Před rokem +3

      ​@@toddqdev Read carefully!!
      last_selected = 0 goes into CREATE EVENT
      the second code
      if (pos != last_selected) audio_play_sound(YOUR SOUND NAME, 1, false);
      last_selected = pos; GOES INTO STEP EVENT

    • @toddqdev
      @toddqdev Před rokem +2

      @@RandomGameBenchmark Alright sorry and thanks!

    • @skymed3095
      @skymed3095 Před rokem +7

      I appreciate your help man, I'm pretty new so I can't figure out how to make small things like this, but this definitely helps
      But what about a playing a sound when you press "accept"? How would you do that?

    • @RandomGameBenchmark
      @RandomGameBenchmark Před rokem

      @@skymed3095 you can do something like
      if keyboard_check_pressed(vk_enter) && !audio_is_playing(ACCEPTSOUND)
      {
      audio_play_sound(ACCEPTSOUND, 1, false)
      }
      This i think, i hope it works good luck

  • @electrosaber0429
    @electrosaber0429 Před 3 lety +140

    This is one of the best tutorials I have seen, please continue this. Doing a great job.

    • @peytonburnham4316
      @peytonburnham4316  Před 3 lety +20

      Thank you so much!

    • @Axogamerlover
      @Axogamerlover Před 8 měsíci +1

      @peytonburnham4316 how did you crate a folder

    • @EyeCantDraw_
      @EyeCantDraw_ Před 5 měsíci +1

      ⁠@@Axogamerloveryou click the plus button at the top of the asset menu and make a group :)

  • @downthispath6538
    @downthispath6538 Před 2 lety +63

    Oh wow you explained everything so easily and clearly that even as a non dev like me can understand. I'm trying to understand this cause I plan to give my sister a gift for her bday next year using your dialogue tutorial. I made her a simple platformer this year following random tutorials here on youtube and she absolutely loved it. So I'll try my hand at something more ambitious next year.
    Thanks a lot for these! I really appreciate it.

    • @Dextrolord
      @Dextrolord Před rokem +5

      How did it go? Did you manage to make something cool?

    • @absin8078
      @absin8078 Před 8 měsíci +1

      Coolest brother(?) ever

  • @Onlyfaff
    @Onlyfaff Před 2 lety +36

    if you want to use the WASD keys for the menu, put an OR state in the middle for example:
    up_key = keyboard_check_pressed(vk_up) || keyboard_check_pressed(ord("W"));

    • @mem3b0i_
      @mem3b0i_ Před 2 lety +6

      It might be good to know that you can also literally type "or" (no quotes btw) and it would do the same thing. But it's better (imo) to get used to typing these | | :)

  • @BritBox777
    @BritBox777 Před 2 lety +39

    Anyone having pixel issue with their 9 slice by the end- I recommend putting the code for centering the x and y in a " x = round( [code] ) " to round it. That solved the issue for me.

  • @martinsnape8104
    @martinsnape8104 Před 2 lety +8

    Having almost bit the edge of my desk in frustration at not getting a menu system working properly, I found this. Such a clear and easy tutorial.

  • @myers4924
    @myers4924 Před rokem +22

    Around 27:57 If you're using a Font that isn't set as by sprite. You could use the below code, with "fnt_menu..." being the custom font. Take this with a grain of salt, it worked for me, but I do not know much about coding.
    height = op_border * 2 + font_get_size(fnt_menu_dungeonfont) + (op_length - 1) * op_space;

    • @Shot666
      @Shot666 Před rokem +1

      ffs tysm

    • @ripihy
      @ripihy Před rokem

      fnt menu doesnt exist apparently??

    • @myers4924
      @myers4924 Před rokem

      @@ripihy fnt menu is part of the font name. My font was named "fnt_menu_dungeonfont", yours could be something else like "Comic_Sans"

    • @RealCrackey
      @RealCrackey Před rokem +3

      @@myers4924 I know this was a month ago but i need an answer desperately, how do you add a normal font into it without it being a sprite font???? i need to know! thank you :)

    • @Pika782
      @Pika782 Před rokem

      tysm!

  • @cleverdragon2744
    @cleverdragon2744 Před rokem +5

    I honestly find these more straightforward and clear than the official gamemaker tutorials. Thanks!

  • @CGJournalist
    @CGJournalist Před 2 lety +76

    If anyone else is trying to use this on a 1920 x 1080 room, the easiest thing to do is to scale his values by 10. For example, where he put "width = 64" in the create page, I put "width = 640". Change this, the height (860), op_border(80), op_space(160) and also the last number of obj_settings --> Create --> line "global.font_main"... from 1 to 5. Then the rest of the math will all make sense. I also changed my font sprite to 70x90 and my textbox sprite to 200x200. Double check all these listed values for a 1920x1080 room and it will all work as demonstrated in the video!

    • @JackHuntYou
      @JackHuntYou Před 2 lety +3

      Thank you for your help!

    • @CGJournalist
      @CGJournalist Před 2 lety +4

      @@JackHuntYou you’re welcome, it’s this god on the video that we really owe our thanks to xD

    • @mr.ranno5432
      @mr.ranno5432 Před 10 měsíci

      What about the center menu?

  • @schlatta-dirtydeeds9351
    @schlatta-dirtydeeds9351 Před 2 lety +11

    When I say this is an upgrade to my previous menu system it is NOT an understatement, thank you! Looking forward to checking out more of your stuff!

    • @xwxlx
      @xwxlx Před 2 lety +2

      !understatement

  • @ksenyajustkidding1484
    @ksenyajustkidding1484 Před 2 lety +19

    i’ve bingewatched all your programming videos and made something… this guide is sooo coool! man i never thought it could be so interesting!!! pleeasaeee continue these tutorials it’s super cool!!!! also im quite surprised that your channel is so small so keep it up !!!!!!

  • @Cyranek
    @Cyranek Před rokem +5

    well spoken perfectly paced informative tutorial

    • @Rykeroli
      @Rykeroli Před rokem

      cyranek rpg confirmed?

  • @disusdev
    @disusdev Před 2 lety +8

    Quick tip: Way to go through menu options without branches: just after `pos += down_key - up_key;` you can add `pos = (pos + op_length) % op_length;` instead of "if" statements

    • @simonl.3461
      @simonl.3461 Před 2 lety

      Nice tip! for some reason my code didn't work with the if statements, but with your code it did.

  • @explodedkidboi3004
    @explodedkidboi3004 Před rokem +3

    I started using GameMaker recently. These tutorials really helped me understand how GameMaker works. Although, i used GameMaker Visual to code, i was able to make sure I was matching the code by useing the Live Preview function, which shows your code if typed out, but doesnt permanently convert it. Thanks for this 😊

  • @carlospintor-fernandez8105
    @carlospintor-fernandez8105 Před 3 lety +17

    Gotta say very well explained for beginners such as myself.

  • @rinkun6689
    @rinkun6689 Před 3 lety +28

    I had to subscribe man seriously you’re a big help c: will you be covering an rpg battle system as well? I’ve been trying to figure out how to do an earthbound type of battle perspective, like how it’s first person but I dunno how to approach it..

    • @peytonburnham4316
      @peytonburnham4316  Před 3 lety +16

      Thank you! And I'm not sure yet what types of gameplay-oriented systems I'll be covering. As far as turn-based combat goes, an Earthbound style system would be one of the easier ones to cover but they're still pretty involved! But never say never, I suppose!

  • @LithtinaVtuber69
    @LithtinaVtuber69 Před 3 lety +49

    Thank you so much for posting this, can't wait for the textboxes, small nitpick though, could you zoom in on your code, sometimes I can't read it but other than that great job

    • @peytonburnham4316
      @peytonburnham4316  Před 3 lety +18

      Oh great idea! I’ll see if I can increase the font size in gamemaker or something before i record the next video!

    • @connerjacobs
      @connerjacobs Před rokem

      @@peytonburnham4316 how do I create a new folder

    • @mixdevelops
      @mixdevelops Před rokem +1

      @@ok-mb1bn even if you do that, its still hard to read it

  • @stevusbrevus4362
    @stevusbrevus4362 Před 26 dny

    This video's quite good, but I do wanna add something for anyone passing through.
    in 15:08, you dont really need to use 2 if statements, you can simplify it down to:
    pos = (pos + op_length) % op_length;
    or...
    pos = (pos + op_length) mod op_length;
    Basically, we do a modulo on where we're selected with op_length.
    Hope this helps!

  • @AngryhammerGames
    @AngryhammerGames Před 2 lety +7

    That was an awesome video! I loved the tempo\speed of the video too. My UI always gets messy when I add sub menus and features. I like what you did as its quick/simple and dynamic. I dont know if it matters much, but I am not sure about having for loops in the draw event. Can be a cpu/gpu killer if your not careful. Lately I like to use a menu_controller object which keeps track of what menu your at and what buttons to show. Then I have button objects that can change as needed in size, text or image. Also more advanced animations and such using delays or loading. They are easy to control too as each menu button is an object and all that entails. It can help when mixing input from mouse, keyboard or joystick as I like to have all of them available. But anyways, I really liked this video and your code is pretty awesome!

  • @reneilabayon2260
    @reneilabayon2260 Před rokem +1

    hey sir, i know its already been a year since you created this tutorial. I just wanted to say thankyou so much, I learn a lot from your videos.

  • @georgedouros4522
    @georgedouros4522 Před 2 lety +6

    Great video it helped me a lot to construct some cool menus in my projects. However I found a small problem, if your submenu has less options than your initial menu level you get an Index error.
    Example:
    options[0, 0] = "New Game";
    options[0, 1] = "Load Game";
    options[0, 2] = "Settings";
    options[0, 3] = "Exit Game";
    options[2, 0] = "Sound";
    options[2, 1] = "Back";
    If you choose Settings you will trigger an index error because pos will be 2 but pos in options[2] takes values 0 and 1, even if you change the pos and menu_level in the Step Event inside the switch statement.
    One way to solve this (bad) is to add an alarm trigger that deactivates the Draw Event for miliseconds OR in my case, I just made a 1d array of menus and I spawn additional objects for each submenus. Again, I'm just mentioning this for educational purposes. This example of menu system you propose is solid and follows good practices. Great job and good luck on your works!

    • @kingofspades9720
      @kingofspades9720 Před 2 lety +10

      I had the same issue, your comment helped me a lot, but, I found a super super simple way to fix it.
      instead of just putting
      //Settings
      case 3: menuLevel = 1; break;
      instead, change the op_Length before changing menu level,
      like this.
      case 3: opLength = array_length(option[1]); menuLevel = 1; break;

    • @ChufoildQQ
      @ChufoildQQ Před rokem

      just number in order from 0,1,2 and so on, of course there will be an error if you jump from 0 to 2

    • @botijooj
      @botijooj Před 10 měsíci

      ​@@kingofspades9720omg thanks so much man, was having a headache with this error

    • @kingofspades9720
      @kingofspades9720 Před 10 měsíci

      @@botijooj Glad it could help!

  • @steevelapointe1152
    @steevelapointe1152 Před 2 lety +1

    your tutorial , are insane, im not even an english speaker, and i have a lot of diffuculty while listening video in english, but not on your video, you are talking clearly, we hear every word you spell, thanks for these tutorial.

  • @Nightfallz23
    @Nightfallz23 Před 2 lety +2

    Amazing Tutorial - I actually supported your Kickstarter and somehow never realized you did tutorials like this. Keep up the incredible work on your tutorials, this was very clear and helpful to expand upon.

  • @Mvolkovin
    @Mvolkovin Před 2 lety +2

    Holy crap man. Excited for Starcross to come out, it looks like an absolute blast. Thank you for doing these tutorials for us in the meantime. You've earned a loyal fan.

  • @LF21Hungry
    @LF21Hungry Před rokem +3

    i know its been quite a while but i really got into gamemaker thanks to you, and i am finally able to make my own games instead of just modding
    thank you, you just got my sub =]

  • @shaneduquette
    @shaneduquette Před 9 měsíci +6

    If you're building this menu into the RPG game from the previous tutorials, and if you want to access the menu from your game, I added this to the beginning of the step event for the player object (obj_player):
    if (keyboard_check_pressed(vk_escape)) {
    room_goto(rm_title_screen);
    instance_deactivate_object(obj_player);
    }
    It makes it so that pressing the escape key (vk_escape) loads the menu (rm_title_screen). It also deactivates the player so they don't show up on top of the menu.

  • @NingyoHimeDoll
    @NingyoHimeDoll Před 2 lety +2

    Great tutorial!
    I suggest putting this video in a playlist, because i couldn't find it while going through your playlists.
    After the RPG basics tutorial series i wanted to watch more tutorials, so clicked on the first dialogue tutorial video because it was in a playlist, and only at the beginning of that video i realized there was a previous video (this one) i had missed, and only because that video mentions it.

  • @scootie_scoot
    @scootie_scoot Před 2 lety +2

    i can't believe you made that font!! it looks just like old rpgmaker games or ds rpgs...i wish i could download it

  • @snoopcena4594
    @snoopcena4594 Před rokem +1

    greatest people on earth

  • @guterversuch6337
    @guterversuch6337 Před 4 měsíci +1

    Bro i love you. thats so many videos of you that helped me. every time i find my answers with you

  • @gargoyled_drake
    @gargoyled_drake Před 2 lety +5

    a lot of cutting, would be nice to be able to just see how you do things from scratch, adding in, importing, creating new folders and so on, other than that it's great.
    don't listen to those that complain about too much information, there is no such thing, but there is a setting on youtube to speed up a video in case people are in a hurry 😜

  • @NoLongerTwee
    @NoLongerTwee Před 3 lety +3

    I love this guy and his tutorials

  • @ashliiiiii
    @ashliiiiii Před 2 lety +1

    Thank you!! This is the best menu tutorial that I've found online, and helped me develop my menu system. I'm just getting into GameMaker2 so this tutorial was very helpful for me. Infinitely grateful!

  • @kingparat1258
    @kingparat1258 Před 2 lety +3

    Hell yeah! Thanks for the stellar tutorial man, hope your game is a success it looks phenomenal!

  • @kkeough5759
    @kkeough5759 Před 2 lety

    You, sir, are the real MVP. This series has been a tremendous kick-start.

  • @superstarichiban
    @superstarichiban Před 4 měsíci +1

    I would love to see this system used for a turn-based rpg combat system!!

  • @TornadoTwisterYT
    @TornadoTwisterYT Před 2 lety +8

    Could you make a tutorial for how to make the buttons in the sub menu (Window size, Brightness, and Controls) actually work?

  • @vela7358
    @vela7358 Před 2 lety

    best tutorial i've done and i've been hopeless with everyone elses tutorials, thanks.

  • @joandersonoliveira6802
    @joandersonoliveira6802 Před 3 lety +5

    thank u so much for creating this kind of content. u're really helping me a lot :)

  • @LunaRiddle77
    @LunaRiddle77 Před 2 lety +1

    literally a life saver for this one WOOO i had been looking for something like this all WEEK THANK YOU

  • @LocalLialec
    @LocalLialec Před 8 měsíci

    that last part when you were trying to say itchio was hilarious lmao

  • @sewagecaidan
    @sewagecaidan Před 2 lety +4

    Hey Peyton this series is helping me develop my own game right now, and I'm very happy that this series exist but I need help with a problem with the menu. My menu select is very fast, if i press up or down i just freaks out and lands on a random option.
    Nevermind, I got it lmao!

  • @commanderuseless1685
    @commanderuseless1685 Před rokem

    Thank you very much for your videos, Peyton - I just recently got started with GameMaker Studio 2 and your videos have been entertaining, educational and extremely helpful!

  • @perra8824
    @perra8824 Před 2 lety +1

    thank u than u this was a tutorial i watched for the first time which gave me no errors right away

  • @indiepunch3443
    @indiepunch3443 Před 3 lety +4

    Amazing, thanks for sharing! I hope you continue to make more! :]

  • @C.OSengoku
    @C.OSengoku Před 10 měsíci

    i fixed the switching menu bit by accident and when the fixing for loop bit played i realized i hadnt fixed anything lol
    it was torture to get back to the error bit BUT THIS TUTORIAL IS TOOO GOATED

  • @fa_speedysnack
    @fa_speedysnack Před 2 lety +4

    Thanks man, this video really helped, though. I do a have a question, Can you make a part 2 where it covers actually setting up stuff like the volume, reso. etc?

  • @lightd2471
    @lightd2471 Před 3 lety +3

    Man, I begg you, make a text box tutorial, you explain things so well and I couldn't find any updated tutorials

    • @peytonburnham4316
      @peytonburnham4316  Před 3 lety +3

      I plan on it soon! Just been busy lately but I’m getting it done!

  • @gabrielpiche5024
    @gabrielpiche5024 Před rokem +5

    i got a problem. The game is running perfectly, i did everything you said, but when the menu opens, the Menu background sprite isn't there anymore. There's just the big black void behind the text and it looks to me like it's not well-centered like it's supposed to. Can you and the others help me, please?
    UPDATE: I found where the problem is coming from. It's the part where you have to position the menu. This part, to be more precise:
    width = _new_w + op_border*2;
    height = op_border*2 = string_height(option[0, 0]) + (op_length-1)*op_space;
    I deleted it and the background menu sprite reappeared, but it looks ugly and it doesn't fit the options nicely. Any ideas on how i can fix it?

  • @danyk1n2
    @danyk1n2 Před rokem +1

    Have a good day too!

  • @oldbomb
    @oldbomb Před 2 lety

    Great video, thank you so much, this was just the right thing to get me to finally program some menu systems for my games!
    I will definitly check you dialogue system too, looking forward to that!

  • @user-kg7in4ce8g
    @user-kg7in4ce8g Před 2 lety +1

    It was very helpful for learning GMS2. much obliged!

  • @Moogy768
    @Moogy768 Před měsícem

    If your menu disappears when you add Center Menu code, try dividing it by different values. I had divide my x by 9 and y by 7 to center it. instead of the /2

  • @Gturtle10x
    @Gturtle10x Před měsícem

    This series has helped me so much thank you

  • @MarkJunior42
    @MarkJunior42 Před 6 měsíci +3

    I got the menu working and all, but for some reason the font I’m using shows up super big and overlaps on each other… anyone know a fix?

  • @DavideScarioni
    @DavideScarioni Před 5 měsíci

    Easily understandable and complete, thank you!

  • @realitygamer3524
    @realitygamer3524 Před 2 lety +3

    Could you do a video on sprint/dash mechanics using the movement script from the rpg series? It'd be really helpful

    • @nathanreyc
      @nathanreyc Před 2 lety +3

      if keyboard_check(shift_key)
      {
      move_spd = 2;
      }
      if keyboard_check_released(shift_key)
      {
      move_spd = 1;
      }
      the values of the move speed can be whatever fits your game

  • @NorthWarden54
    @NorthWarden54 Před 2 měsíci

    Your an actual life saver man with you videos

  • @arti5769
    @arti5769 Před 2 lety

    Great tutorial. Just watched it and gotta have a go on my own now. I also looked up your game. It sounds interesting and I'll have a eye on it. Especially since you also go for a Switch version :)
    I'll need your other tutorials too, so, keep going. It'll help to get to know your game to a bigger public.

  • @_bytebeak
    @_bytebeak Před 2 lety +1

    I love your tutorial series so much. In my opinion, the most helpful one's out there. I really take my time watching them quite thoroughly (I'm a very beginner and need the time to understand it all). I have one open question, maybe someone who reads this find the time to explain it to me.
    So we define the position variable in the create-event. (pos = 0). Then, in the step event, we define the current position depending on which buttons we press, and highlight the selected string. My question is: how does GM know from the start, that the pos we defined overlaps with the same position as the first string in our array ? (In this example: "Start Game").
    I'm pretty sure I'm overthinking it. But I really want to understand how it works, so I'd be super thankful for any help I'd get here!

    • @ChufoildQQ
      @ChufoildQQ Před rokem

      I don't speak your language, but if I understood correctly from the translator what your question is, then the gmc initializes what is in create first, and then step, so when it comes to step, the gmc checks pos with option

    • @ChufoildQQ
      @ChufoildQQ Před rokem

      in the option, the zero cell is equal to "start game" and since the position is 0, then the zero cell will be output, and the zero cell is the start game)

    • @ChufoildQQ
      @ChufoildQQ Před rokem +1

      I'm sorry it's so late, but I couldn't help but answer when I saw that the question was unanswered

  • @JayHurst1
    @JayHurst1 Před měsícem

    I love this menu system. For some reason though on my thinner letters like l and i, it leaves a huge space that shouldn’t be there while all the other letters are correctly spaced

  • @night_fall2561
    @night_fall2561 Před 2 lety

    Oh my god, I love your tutorials confused why doesn't have more likes

  • @SangHendrix
    @SangHendrix Před 3 lety +6

    I'm new to coding, I have zero knowledge of it and even tho your videos are basic, I'm still worried if I can understand all of this. Like what's the logic behind those codes? Do I need to understand it first or I just need to follow the tutorial and other tutorials and wait for the day I eventually get it?

    • @peytonburnham4316
      @peytonburnham4316  Před 3 lety +6

      If you haven’t watched my “How to make an RPG” series, watch that first, it goes by everything very slowly and i explain how everything works! It’s a bit simpler than this video. At first you’re going to be learning a lot at once so it might feel like you don’t understand, but thats how learning ANY new thing works! Keep following beginner tutorials, pay attention to them very closely, and REWATCH many of them after you’ve finished them. That will help a lot. Soon lots of this stuff will just stick with you and you’ll find your footing! Just keep going!

  • @totallytoffy
    @totallytoffy Před rokem +1

    Hippity Hoppity, Your code is my property!

  • @digitalswordplay
    @digitalswordplay Před 3 lety +8

    Great tutorial! - How would I go about adding a little triangle indicator beside the text when cycling through the options?

    • @scootie_scoot
      @scootie_scoot Před 2 lety +1

      i second this!! i've been struggling to find an updated gamemaker tutorial about this

    • @PinesOfChaos
      @PinesOfChaos Před 2 lety +4

      In the draw event, you'd do something like: draw_sprite(spr_triangle, 0, x, y+op_border+(op_space*pos)) may need to offset the values depending on your sprite, but this should work

  • @lannygilbertson3585
    @lannygilbertson3585 Před 2 lety

    you are a treasure trove good sir. Thank you for these.

  • @kersod9216
    @kersod9216 Před měsícem +1

    HELP, when I try to start the game, it says that, the code "draw_text( x+op_border, y+op_border + op_space*i, opción[i]) it's not set before reading it, can someone tell me how ti fix it ????? 😭😭😭

  • @Wulfnstein
    @Wulfnstein Před 6 měsíci +1

    Came for a menu tutorial, but learned you can have a custom font instead. scuse me as I go figure out how to do that first. xD

  • @TampopoInteractive
    @TampopoInteractive Před 2 lety

    This is so great and simple to implement! Thank you!

  • @D4stro
    @D4stro Před 2 lety +3

    is there a way to make this menu pop up over the screen and make the game pause with it? If so please make a part 2 to this showing how to code it :)

    • @SunnieMunch
      @SunnieMunch Před 2 lety +2

      my code isn't perfect but I have something like this working well enough in my game describing what you're asking. For set up I have 2 instances layers for my game, one with all of the main elements and visuals like the player, obstacles, interactables, etc and one just for holding meta objects. In the step event of an overall controller object, I set up a if key pressed input that would be pausing the game, and use this line that toggles the state of being paused and not:
      global.gamePause = -global.gamePause + 1;
      then I have an if then statement that says if the game is paused, everything on the main game layer's image speed will be 0 to stop all animations with the instance of the menu being created on a separate layer above (additionally in the player's code if the game is paused, all movement code is stopped). else, the image speed of the main game layer is set back to it's original and the menu instance is destroyed.
      There may be a better way to do this or explain this but it's the best I have for now!

  • @Learnjapanesefromsomeguy
    @Learnjapanesefromsomeguy Před 3 lety +3

    I can press spacebar on 'settings' and have it take me to the next menu but when I click "Back" it does not go back to the pause menu. Instead, it takes me into my game as if I had pressed "Start Game."
    Has anyone else had this issue, or could possibly guess as to why this might be happening?
    Edit:
    Never mind. I figured it out.
    I had typed accept_key = keyboard_check(vk_space) instead of accept_key = keyboard_check_pressed(vk_space).
    So, 'Back' was actually bringing me back to the pause menu, but because the spacebar was still pressed, it would select "Start Game" immediately then I would find myself in my game without ever seeing the pause menu.

    • @peytonburnham4316
      @peytonburnham4316  Před 3 lety +3

      Glad you figured it out on your own! It's great to start building that skill of being able to identify little problems like that and knowing what was actually happening! Great work!

  • @eggman5712
    @eggman5712 Před 7 měsíci +1

    I don't know why but I can't for the life of me get the camera centering to work, I've got the
    x = camera_get_view_x(view_camera[0]) + camera_get_view_width(view_camera[0])/2 - width/2;
    y = camera_get_view_y(view_camera[0]) + camera_get_view_height(view_camera[0])/2 - height/2;
    but for whatever reason it disappears whenever I use this code.

    • @unoreversecard8129
      @unoreversecard8129 Před 7 měsíci +1

      I had this issue and it ended up being me forgetting to configure my viewport lol
      Make sure U enabled viewport, make viewport 0 visible, configure your camera properties height and width and viewport properties width and height to whatever your games properties are and have the camera follow the obj_tile_menu (or whatever you chose to call your menu object) and it should show up when you run the game 👍

  • @klickert
    @klickert Před rokem +1

    POV : you watch that hole Tutorial from 10 PM to 1:30 PM ... gn

  • @user-hj7rb8vt4c
    @user-hj7rb8vt4c Před 10 měsíci

    These guides need text docs, scrubbing through when things don't run is a pain

  • @dc37wwe2kmods
    @dc37wwe2kmods Před rokem +3

    why are my texts gibbirish? Like Start Game is like Tubsu Gbnf?

    • @dc37wwe2kmods
      @dc37wwe2kmods Před rokem

      Fixed my problem: I missed a character on my font. Be sure to not miss one or else it'll go chaotic.

    • @ScrDesh
      @ScrDesh Před 11 měsíci +1

      tubsu gbnf, words i will never forget lol!
      I did the same thing, missed the speech marks when making the font

  • @gtbgabe1478
    @gtbgabe1478 Před 10 měsíci +2

    I'm having a small problem where when i select "back" to return to the main menu, it imediatly selects the top option, and i have no idea why

    • @Busterbrown1902
      @Busterbrown1902 Před 10 měsíci

      I had the same issue, the problem was I forgot to put "break;" in the switch(menu_level) cases.

    • @gtbgabe1478
      @gtbgabe1478 Před 10 měsíci

      @@Busterbrown1902 Turns out it was something way stupider
      instead of "Keyboard_check_pressed(vk_space)"
      I had put "Keyboard_check(vk_space)"

  • @KingOfFoolz
    @KingOfFoolz Před 2 lety +5

    Great video! But I still have a few questions. How would I go about making 2 more submenus? I tried just essentially following all the steps again creating 2 more cases. But my new submenues only have 2 cases in them each. But for some reasong when I try to open them it gives me an error. Saying there was something wrong on my Draw event 12, this one, draw_text_color(x+op_border, y+op_border + op_space*i, option[menu_level, i], _c, _c, _c, _c, 1);

    • @mcdaysalive6586
      @mcdaysalive6586 Před 2 lety +2

      If you ever figured it out can you let me know, hitting the same error message and can't seem to figure it out...

    • @blanktheblanket8081
      @blanktheblanket8081 Před rokem +2

      You need to update your op_length variable when switching to a smaller menu(in your example a menu with 2 cases), let's say that the main menu has three cases, when you switch into your smaller submenu without updating op_length, gamemaker remembers that op_length is three so when it's trying to draw the submenu it returns an error because there is no 3rd case.
      Here's my code in the step event in case you don't understand:
      //Check for accept input
      if acceptK
      {
      //Switch pos
      switch menuLevel
      {
      //Main menu
      case 0:
      switch pos
      {
      case 0: room_goto_next(); break;
      case 1: menuLevel = 1; break;
      case 2: menuLevel = 2; opLen = menuLevel; break; //Updating opLen to current menu level
      case 3: game_end(); break;
      }
      break;
      //Options menu
      case 1:
      switch pos
      {
      case 0: break;
      case 1: break;
      case 2: break;
      case 3: menuLevel = 0; break;
      }
      break;
      //About menu
      case 2:
      switch pos
      {
      case 0: break;
      case 1: menuLevel = 0; break;
      }
      break;
      }
      }
      Sorry for late response and I hope this helps :)

  • @nickgennady
    @nickgennady Před 2 lety +2

    Damn. Thanks for Tutorial. Your demo is windows only sadly which I only have m1 Mac which does not allow for bootcamp :(
    Congrats though on the kickstarter for 15K.

  • @ponez8518
    @ponez8518 Před 2 lety +4

    I'm running into a few problems while doing it. First of all, the object I put in the room is very small when I run it. What should I do? and finally, can we get the font ready instead of creating it ourselves?

    • @DanielAlvarez-oq8ex
      @DanielAlvarez-oq8ex Před 2 lety +2

      Same issue here. could you fix it?

    • @user-cu6vg1eo9r
      @user-cu6vg1eo9r Před 2 lety

      i met the same problem, have you resolved it?

    • @Wakakakakaku
      @Wakakakakaku Před 2 lety +1

      1. just put object in the room, dont stretch It :)
      2. create font(right click on workspace>assets>create font), name it font_main(or whatever you want), then in obj_settings create event instead of tutorial code put these code: global.font_main = font_main;

    • @ItswildII
      @ItswildII Před 2 lety

      @@Wakakakakaku how would i type this code for the clean up would it be
      it says
      idk what im doing wrong anytips?
      trying to delete non-existing font.
      at gml_Object_Obj_settings_CleanUp_0 (line 1) - font_delete(global.font_text);

  • @eogabs_
    @eogabs_ Před 3 měsíci

    why does my menu vanishes when i use that one last code (setting the center menu part)? I believe i did everything as the video shown
    //center menu
    x = camera_get_view_x(view_camera[0]) + camera_get_view_width(view_camera[0])/2 - width/2
    y = camera_get_view_y(view_camera[0]) + camera_get_view_height(view_camera[0])/2 - height/2

  • @Deadsmile1123
    @Deadsmile1123 Před 4 měsíci +1

    i got this error
    ERROR in
    action number 1
    of Create Event
    for object oSetting:
    global variable name 'font' index (100030) not set before reading it.
    at gml_Object_oSetting_Create_0 (line 1) - global.font.main = font_add_sprite(xxxfont, 32, true, 1)
    how do i fix it?

    • @nemuri6295
      @nemuri6295 Před 4 měsíci

      Remove global and just write "draw_set_font(font_main);" instead. That's what worked for me.

  • @AdriannaS-zy3pi
    @AdriannaS-zy3pi Před 14 dny

    I keep entering a code error whenever I try to load up my game. The issue is with the 5th line of code in obj_settings and create. It keeps saying that font_main is not established and idk what to do :(

  • @sousukesagara6958
    @sousukesagara6958 Před rokem +4

    What happens if you don't want to use a custom font or if you just want to use a downloaded font?

    • @KokomiFish0
      @KokomiFish0 Před 4 měsíci +2

      just write the font you have in the "draw_set_font();" line and don't add the custom part :D

    • @VeilOfBlood
      @VeilOfBlood Před 2 měsíci

      @@KokomiFish0oh my god thank you so much your a doll😭😭

  • @RicardoADev
    @RicardoADev Před 2 lety

    I'll be trying this out! Thank you! However, I feel it's easier to use the Draw GUI event.

  • @ty88
    @ty88 Před 2 měsíci

    this repeating whistling song is driving me crazy

  • @FredrickVonBeethoven
    @FredrickVonBeethoven Před 26 dny

    the background on my menu seemingly duplicated itself without its animation behind the first one (that has the animation) and the second one is wider than the first, anyone know how to fix this?

  • @lieutenantashe6673
    @lieutenantashe6673 Před 3 lety +1

    This very helpful, thank you a lot!

  • @Dongdorodong_
    @Dongdorodong_ Před 5 měsíci

    If you've been having trouble with deformed sprites like I have, here's a workaround.
    Simply change the Tile Mode of each part of the sprite's Nineslice to Repeat.

  • @prod.kasper
    @prod.kasper Před 2 lety +3

    what if the next menu level has less options than the first menu level? I kinda merged your video and shaun spalding's, I have a little arrow to show what you're selecting as well as colour. But yeah I have that error. Here's my draw code, the error is "var txt = menu[menuLevel, i]"
    for (var i = 0; i < menuItems; i++)
    {
    var offset = 2;
    var txt = menu[menuLevel, i];

    • @KingOfFoolz
      @KingOfFoolz Před 2 lety +1

      I think I'm having the same issue as you. Did you ever figure it out?

    • @prod.kasper
      @prod.kasper Před 2 lety +1

      @@KingOfFoolz no sadly I did not. I kinda gave up on it lol but there has to be some sort of solution

  • @Abdulrahman_tramsy
    @Abdulrahman_tramsy Před 3 lety +3

    Can you please do a tutorial for text boxes and how did you do the text box that was in the end of part 6

    • @peytonburnham4316
      @peytonburnham4316  Před 3 lety +1

      Yep I'm still planning on doing it! I have it outlined and everything I just need to find some time in the next few days to record and edit it!

    • @Abdulrahman_tramsy
      @Abdulrahman_tramsy Před 3 lety +2

      @@peytonburnham4316 and whenever will you do it iam waiting for you bro

  • @wanderslight9625
    @wanderslight9625 Před 2 lety +2

    Quick question regarding the initial length and width values.
    In the beginning of the tutorial you set width and height values for the menu border and later on you made the menu border size dependent on the text and fonts.
    Would the initial length and width values still matter? Or could you just set them to 0 and let the step event change them dynamically according to what’s being displayed?

    • @shabanotti
      @shabanotti Před 2 lety +1

      I chaged them to 0 and it seems to work fine so I think it's ok to initialize them all at 0.

  • @MoBoRoS
    @MoBoRoS Před 2 lety +5

    Hi There Peyton, followed your tutorial to the dot! The difficulty skyrockets in this one compared to your 6-part series. I love your tutorials so far! they are really helpful!
    I managed to make the menu work as intended but with a few problems:
    1st of all I do not know how to adjust the height and width of the box and letters to make them appear a bit bigger compared to the screen and 2nd when I click on "back" on the settings menu the game crashes and it returns the following error:
    ############################################################################################
    ERROR in
    action number 1
    of Draw Event
    for object obj_title_menu:
    Variable Index [3] out of range [3]
    at gml_Object_obj_title_menu_Draw_0 (line 5) - var _op_w = string_width(option[menu_level, i]);
    ############################################################################################
    gml_Object_obj_title_menu_Draw_0 (line 5)
    Thanks again in advance! Keep up the awesome work!!

    • @gamerompstudios
      @gamerompstudios Před 2 lety

      I'm having this same issue with the menu options. The only way it works for me currently is if both menus have the same amount of choices. My best guess is because arrays now only come in 1D, no longer 2d, technically.

    • @fatmen7391
      @fatmen7391 Před 2 lety +1

      i'll help u

    • @fatmen7391
      @fatmen7391 Před 2 lety +2

      STEP EVENT
      //get inputs
      up_key = keyboard_check_pressed(vk_up);
      down_key = keyboard_check_pressed(vk_down);
      accept_key = keyboard_check_pressed(vk_enter);
      //store number of options in current menu;
      op_length = array_length(option[menu_level]);
      //move through the menu
      pos += down_key - up_key;
      if pos >= op_length {pos = 0};
      if pos < 0 {pos = op_length-1};
      //using the options
      if accept_key {

      var _sml = menu_level;

      switch(menu_level) {

      //pause menu
      case 0:
      switch(pos) {
      //start game
      case 0: room_goto_next(); break;

      //settings
      case 1: menu_level = 1 break;

      //quit game
      case 2: game_end(); break;
      }
      break;

      //settings
      case 1:
      switch(pos) {
      //window size
      case 0:


      break;
      //brightness
      case 1:


      break;
      //controls
      case 2:


      break;
      //back
      case 3:
      menu_level = 0;
      break;

      }
      break;

      }
      //set position back
      if _sml != menu_level {pos = 0};
      //correct option length
      op_length = array_length(option[menu_level]);
      }

    • @fatmen7391
      @fatmen7391 Před 2 lety +1

      CREATE EVENT
      width = 64;
      height = 104;
      op_border = 8;
      op_space = 16;
      pos = 0;
      //pause menu
      option[0, 0] = "Start Game";
      option[0, 1] = "Settings";
      option[0, 2] = "Quit Game";
      //settings menu
      option[1, 0] = "Window Size";
      option[1, 1] = "Brightness";
      option[1, 2] = "Controls";
      option[1, 3] = "Back";
      option[2, 1] = "select";
      op_length = 0;
      menu_level = 0;

    • @fatmen7391
      @fatmen7391 Před 2 lety +1

      DRAW EVENT
      //dynamically get width and height of menu
      var _new_w = 0;
      for (var i = 0; i < op_length; i++)
      {
      var _op_w = string_width(option[menu_level, i]);
      _new_w = max(_new_w, _op_w);
      }
      width = _new_w + op_border*2;
      height = op_border*2 + sprite_get_height(spr_main_font) + (op_length-1)*op_space;
      //center menu
      x = camera_get_view_x(view_camera[0]) + camera_get_view_width(view_camera[0])/2 - width/2;
      y = camera_get_view_y(view_camera[0]) + camera_get_view_height(view_camera[0])/2 - width/2;
      //draw the menu background
      draw_sprite_ext(sprite_index, image_index, x, y, width/sprite_width, height/sprite_height, 0, c_white, 1);
      //draw the options
      draw_set_font(global.font_main);
      draw_set_valign(fa_top);
      draw_set_halign(fa_left);
      for (var i = 0; i < op_length; i++)
      {
      var _c = c_white;
      if pos == i {_c = c_yellow};
      draw_text_color(x+op_border, y+op_border + op_space*i, option[menu_level, i], _c, _c, _c, _c, 1);
      }

  • @ahsaayumu
    @ahsaayumu Před 2 lety

    I excuse in advance for bad English
    If your viewport has a number but the window resolution has an higher one (something like the viewport being 288x216 and the window being 864x648) and you're trying to make a pixel art game then you might have a problem, the pixels will have a bad scale due to the width being a odd number, to resolve that problem, add this line:
    if _new_w%2 == 1 {_new_w += 1};
    It will check if it's an odd number, then add 1 to the variable to make it an even one

  • @ClintRayJohnson
    @ClintRayJohnson Před 2 měsíci

    Is there any way to use the sprites that come in with GM2 rather than making your own? I really like the look of MS Gothic and I want to find a way to use that instead, but it's just a font. Not a sprite.

  • @kanglongbutler
    @kanglongbutler Před rokem +2

    Thank you for the tutorial, it's really well made. I need help please; I've been trying to find a way to make a pause menu like in the beginning of the video with but it keeps telling me that op_length isn't set before being read. Here's my code :
    In the step even of the player object:
    pause_key = keyboard_check(vk_escape);
    if pause_key = 1
    {
    instance_create_layer(0, 0, "Instances", obj_pause_menu);
    }
    I haven't made any code to remove the instance yet because I'm not able to create it in the first place.
    I'd really appreciate any help, thanks.

    • @jcdenton7273
      @jcdenton7273 Před rokem +1

      remove the "= 1" from the if statement. also when checking for things in if statements, you must use two equal signs. one equal sign means that you are setting the value of something, and two equal signs are how you check for the value of something inside a conditional (which is if statements, while statements, etc.). also the pause_key variable would be a boolean, which is true or false. checking if it's equal to one wont work because one is an integer, and pause_key is not an integer value. you would use if pause_key == true. however, that is unnecessary when checking if a boolean is true. hope this helps and was informative for you, id recommend watching some coding basics tutorials. learning things in once language can translate to all languages, even with syntax differences theres universal things that you need to know in coding

  • @spacecase7331
    @spacecase7331 Před 3 lety +5

    Great tutorial overall, loved it! Just one question, how would I add a sound effect every time I switch to a new option?

    • @TampopoInteractive
      @TampopoInteractive Před 2 lety

      I’m not the video poster, but in the step event within the input checks, where there are two if loops under “//move through the menus”, you could put an audio play in each of those loops.

    • @mproxima4791
      @mproxima4791 Před 2 lety +1

      probably you already solved but I went this route work pretty well right now.
      if up_key
      {
      audio_play_sound(sound,1,0)
      }
      and same for the down key

  • @p0pst1cle4
    @p0pst1cle4 Před 2 lety

    This man is reason why ww3 never started!