This has to be the most in depth, structured and still short tutorial series on the internet. Very well done! I really like yourr planning and tidy approach to things.
Just wanted to pop in and say THANK YOU! Your videos are incredibly useful, and so very easy to understand. If I ever need help with a new system, you're my first stop, because I know that if you explain something, I'll understand it. Your help has been invaluable in developing my first game, so I'm happy to say thanks by signing up as a patron! Please keep up the awesome work!
Thanks so much, Jamie! I'm thrilled to hear that. I'd love to see what you're working on, if you're getting to a stage where you can show off your work! Feel free to @FCosmonaut on twitter anytime! :)
This is on a whole new level! Just when I thought I was a decent coder I realize I know nothing!!! :) Absolutely brilliant @FriendlyCosmonaut!!!! Brilliant!
Absolutely lovely series of tutorial. Just really, thank you for your work, these systems are perfect and are nice modules that can be inserted anywhere without changing every line of code.
Brilliant!! I swapped out the Draw Circle for Draw Sprite, and Added a Shurikan as the slider handle..Also, this is great coding, it plugged straight into my Game, as is, with no messing, just a couple of variable names changed.
Omg you are so in a hurry lol! Great tutorial though, you really inspired me to be cleaner with my code because I feel like you are in another level of code management xD
Yeah I think I rushed through a couple of these videos too quick. I'm going to leave a bit more time for the typing segments in future videos :). But thanks!
Yeah at 19:00 I get an error "illegal array use". It's because of the line: current_array[current_val] No matter what I do, it crashes with that code. Please help? :)
hey the "var circle_pos ((current_val - current_array[1]) / current_array[1] - current_array[0]" doesn't work! can anyone tell me an alternate way to write that line?
I had the same problem, it was because the 'var circle_position' was declared before the 'var current_array'. Also, in your comment you didn't put the '=' between var circle_pos and the operations, i don't know if you put it in the code tho.
Love this video, but I've noticed we don't get to check for errors until quite a bit into the video. It would be awesome to test the code as it's written so I know I'm following along. Thanks so much for this short video series❤ Most menu tutorials aren't great so this is godsend 🙏
@@pupaproductions4784 i know the fear of closing spaces friend! speak freely to me and me can help!!!red speech knows how to FLAG nor FAIL...SERIOUSLY humans.
Seven months late, but you should learn how drawing sprites works. The origion of your sprites need to fit the draw position. It's pretty simple once you understand how sprites work :)
Ah, I could probably do this in a future one! It might be a ways off though: if you're keen to look into it now, I'd suggest using the device_mouse_y_to_gui() to get the mouse position. Then to check which "element" the mouse is selecting, when we loop through and draw all the elements, you could see if the mouse is near the y position of the one we're currently drawing. (By near, you could check if it's within y_buffer/2 up or down). If it is, then set the selection to that element.
i have a question do you maybe know how to make a slide bar mouse controlled with like a rectangle collision i just don't know how to make a simple not complex check for mouse sliding so if the mouse slides to left then slide to left
my suggestion for a basic system would be to check the mouses position to make sure that you are "in range" of the element. Then check for a mouse button down event using mouse_check_button_pressed(mb_left). While the mouse button is clicked, i would make the pointer invisible, using window_set_cursor(cr_none), and set a variable to store your mouse x position at the time of clicking. Then check the current mouse x position and move your slider accordingly, probably based off a percentage of the size of your gui. Once the mouse_down event is over, make your cursor visible, and make sure you are set for new inputs for normal menu operation.
@@FriendlyCosmonaut I’m sorry that I’m writing this so late but I’ve been having extreme trouble getting anything be affected by the mouse. I’ve used both the y_buffer and device_mouse_y_to_gui but to no avail. Plz help, sorry for this being years after the video was posted, and thx for the video it was overall super helpful
Two questions I am having a lot of trouble understanding why people use the "var" word in front of the variable, as opposed to leaving it off? Also, why bother assigning another variable to things, such as gwidth = gobal.view_width. Can't you just use global.view_width, directly in the function itself, instead of asking for gwidth, which points back at global.view_width? Is this for readability, or does this serve a performance purpose, or both? thanks!
Its kind of both. Why they use ”var” in front of a variable is a way of asigning a variable that will be removed when the game updated. Theyre also a little faster than normal variables.
Dang, all the text displays on the screen "resume, settings, exit" but its all squished together on the width and the height. Maybe I need to try setting the global.view_width to display_get_width() instead I will post if this solves it or makes it worse.
Well I figured out that the view_height was set to camera "width" and vice versa which is why it was squished looking. Now the test simply is just small but not squished looking anymore.
This is an awesome idea, but I have one question. When you go from page to page, it remembers what option you were on for that page. How do I get it so it resets back to the first choice when you go back to a page?
I keep getting "Data Structure with index does not exist" in the draw gui event where im initializing the ds_height to ds_grid_height(ds_grid), ds_grid being set to menu_pages[page]. I had to do my create event slightly differently because I'm using Game Maker Studio 1.x so I couldn't initialize the array in the same way. Otherwise they're identical as far as I can see. title_music = sndTitle; // Title music for my game, ignore. global.multiplayer = false; // Multiplayer mode for my game, ignore. pause = true; view_width = view_wview[0]; view_height = view_hview[0]; display_set_gui_size(view_width, view_height); enum menu_page { main, settings, audio, graphics, controls, height } enum menu_element_type { script_runner, page_transfer, slider, shift, toggle, input } // Create Menu Pages: // *NOTE* here I could not use the brackets around each parameter like in the tutorial, // For whatever reason that doesn't work in 1.x, but I feel like that shouldn't matter. ds_menu_main = create_menu_page ( "RESUME", menu_element_type.script_runner, resume_game, "SETTINGS", menu_element_type.page_transfer, menu_page.settings, "EXIT", menu_element_type.script_runner, exit_game ); ds_settings = create_menu_page ( "AUDIO", menu_element_type.page_transfer, menu_page.audio, "GRAPHICS", menu_element_type.page_transfer, menu_page.graphics , "CONTROLS", menu_element_type.page_transfer, menu_page.controls , "BACK", menu_element_type.page_transfer, menu_page.main ); ds_menu_audio = create_menu_page ( "MASTER", menu_element_type.slider, change_volume, 1, 0,1 , "SOUNDS", menu_element_type.slider, change_volume, 1, 0,1 , "MUSIC", menu_element_type.slider, change_volume, 1, 0,1 , "BACK", menu_element_type.page_transfer, menu_page.settings ); ds_menu_graphics = create_menu_page ( "RESOLUTION", menu_element_type.shift, change_resolution, 0, "640 x 360", "1280 x 720","1920 x 1080" , "WINDOW MODE", menu_element_type.toggle,change_window_mode, 1, "FULLSCREEN","WINDOWED" , "BACK", menu_element_type.page_transfer, menu_page.settings ); /* I did not want to use controls yet, which is why this is commented out. ds_menu_controls = create_menu_page ( "UP", menu_element_type.input, "up", gp_padu , "DOWN", menu_element_type.input, "down", gp_padd , "RIGHT", menu_element_type.input, "right", gp_padr , "LEFT", menu_element_type.input, "left", gp_padl , "BACK", menu_element_type.page_transfer, menu_page.settings ); */ // This is where I'm initializing the menu_pages array. I had to assign each value individually because of 1.x. // again, I feel like this should definitely still work. page = 0; menu_pages[0] = ds_menu_main; menu_pages[1] = ds_settings; menu_pages[2] = ds_menu_audio; menu_pages[3] = ds_menu_graphics; var i = 0, array_len = array_length_1d(menu_pages); repeat (array_len) { menu_option[i] = 0; i++; } //Just in case that actually does all check out as I suspect it most likely does, //here's my create_menu_page() script. /// create_menu_page("Name", type, entries...) var arg, i = 0; repeat (argument_count) { arg[i] = argument[i]; i++; } var ds_grid_id = ds_grid_create(5, argument_count); i = 0; repeat (argument_count) { var array = arg[i]; var array_len = array_length_1d(array);
var xx = 0; repeat (array_len) { ds_grid_id[# xx, i] = array[xx]; xx++; } i++; } return ds_grid_id; // Everything above is exactly the same as in the tutorial, besides the fact that I decided not to use difficulty and controls for now. Thank you so much in advance to anyone who is able to fix this issue for me. I'm trying to use this system for a game I intend on putting on Steam as my first actual release, so a quick response would be greatly appreciated!
i hope you eventually managed to fix your project, but i just wanted to say thank you cos you helped me fix the issue of mine not being able to move past my audio/difficulty/resolution/exit page. i hadnt declared what each individual page was in an array like below (menu_pages[0] etc) and i forgot the i++; at the end lol page = 0; menu_pages[0] = ds_menu_main; menu_pages[1] = ds_settings; menu_pages[2] = ds_menu_audio; menu_pages[3] = ds_menu_graphics; var i = 0, array_len = array_length_1d(menu_pages); repeat (array_len) { menu_option[i] = 0; i++; }
can somone please help me? I can select the "settings" option from the main menu but then after that I can't go back, as I can't interact with the back option or any other options. edit: I realize now its just skipping over to the audio page and completely avoiding the settings, still need some help figuring it out- edit2: Figured it out after a bit of me having an existencial crisis lol, apparently the order of the menu_pages variable DO matter, for example: menu_pages = [ds_menu mian, ds_settings, ds_audio, etc etc] would be correct and take you in order, but if its out of order it'll place you in witchever comes first- like if you siwtched settings and audio, it'll take you to audio when you press settings etc-
I have problems when I start doing the right side. Having registered the code for DIFFICULTY, I launch the game to check, and when I go to the DIFFICULTY section, an error appears: "trying to index a variable which is not an array" draw_text_color (rtx, rty, left_shift + current_array [current_val] + right_shift, c, c, c, c, 1); As I understand it, the problem is in "current_array [current_val]" The same problem is in the AUDIO section. If something is missing from me, the GRAPHICS section in CONTROLS is because they are not needed in my game. Thanks.
im having a problem. whenever i press the button to go to the next page it brings me to audio, but when i commented out audio it brought me to people. so its just skipping over the settings. PLEASE HELP
The "index" of each page is just set by their order in the data structure. You're probably just telling it to go to the wrong "number" page, so I'd suggest just carefully combing through the code and making sure everything is set correctly. If everything looks fine there, then it might be a problem with how you've set the data structure up (check in debug mode if the order of everything in the data structure is what you expect it to look like)
I was having the same issue as this person. I had set up my menu_page enum like so: enum menu_page { main, play, settings, audio, graphics, controls, height //to grab # of entries in enumerator } However, I realized "play" isn't actually a page (in my case it'll execute code taking the game to another room), and when I got rid of it, my menus started working correctly.
Hey FriendlyCosmonaut! I got one problem with circles in the sound menu. They appear much further (to the right) from the lines. Are there any solutions? (I watched the video several time but couldn't figure out what's wrong).
I'm having a problem with this I put the code in as you said but upon booting the game it says this: draw_text_color(rtx,rty,left_shift+current_array[current_val]+right_shift,c,c,c,c,1); is an illegal use of an array but it shouldn't be. Anyone know a fix for this?
i guess get rid of draw_line_width and draw_circle_color and write draw_text_color(rtx,rty,…,c,c,c,c,1); Instead of the three dots just put what was on the tutorial
Update: I figured out what the problem is but still am unable to find a remedy. Basically, upon creation of the menu, the menu_element_type.script_runner, menu_element_type.page_transfer, etc. are not being properly assigned in the create event Example: // Create Event enum menu_element_type { script_runner, page_transfer, slider, shift, toggle, input } // Create Menu Pages ds_menu_main = create_menu_page( ["RESUME", menu_element_type.script_runner, resume_game], ... etc. every single value where menu_element_type.script_runner is, is just being set to 0 even when I put page_transfer which I found out through the debugger. Debugger: ds_menu_main > 1 > 0 = 0, 1 = 0, 2 = 0 screenshots: imgur.com/a/z4AkkmL and imgur.com/a/VYdJ8mN
update, after a total of 18 hours of headbanging on the wall, I have found the solution. In my menu_create_page script, I had for (var xx = 0; xx < arr_len; x++) { ds_grid_id[# xx, I] = arr[xx]; xx++; } // Because I prefer for loops rather than repeat loops. but I forgot to remove the xx++; Another issue was in the Draw GUI Event in the Menu Object, where I had for (var yy = 0; yy < ds_height; yy++) { // I forgot to add the rty = start_y + (yy * y_buffer); so it was returning a read before set error. switch().... etc. } Hope this helps anyone with the same or similar error!
I cannot seem to find where you mentioned it. . .but what does the '#' mean when you call it here ds_grid[# 1,yy]? I understand that the ds_grid is essentially a 2d array; and that the '1' is the x-coordinate where the 'yy' is the y-coordinate, but don't get the '#'.
So these are called "accessors" - they're different for every data structure type. The grids use "#", while ds_lists use "|", and ds_maps use "?". It's quite arbitrary. But basically, they're just a "quick way" to get access to a grid. There are actually functions that will do the same thing: ds_grid_get(index, x cell position, y cell position); //gets the value a cell holds ds_grid_set(index, x cell position, y cell position, value); //sets a cell equal to a value But instead of using those, you can just write value = ds_grid[# cell_x, cell_y]; ds_grid[# cell_x, cell_y] = value; So think of it like a shortcut!
I get an error on the 3rd row of the step event. It's not shown with a typical red warning, yet when I start the game, it crashes and keeps bringing up this line. It looks EXACTLY as you typed it though. :(
Can i get your source code please.. NO matter which option i chose audio,difficulty or graphics all of them draws the same exact strings "Master","Sound","Music","back". I just did exactly as you did but dont know where the error is.
My options texts only shows "SETTINGS", "SETTINGS", "SETTINGS" instead of "RESUME", "SETTINGS", "EXIT". Everything else works like it will goto the settings menu but the same problems remains, it only shows one of the menu names and just repeats them. Im not sure where I messed up at but the draw event I have is: //Draw elements on left side draw_set_valign(fa_middle); draw_set_halign(fa_right); var ltx = start_x - x_buffer, lty, xo; var yy = 0; repeat ds_height { lty = start_y + (yy*y_buffer); c = c_white; xo = 0; if yy == menu_option[page] { c = c_orange; xo = -(x_buffer/2); } draw_text_color(ltx+xo, lty, ds_grid[# 0,yy], c,c,c,c,1); yy++; } Any idea where I made my error or maybe I made the error somewhere else?
Sorry for the late reply (I'm still on holidays!). Hmm, can you check the content of the grid in the debugger (as I show in the previous video) and see if the strings are correct there? If they're not, that means the problem would actually be where you STORE the data for the strings, ie. in the create_menu_page script. I'd look in the loop and ensure that the arrays are being transferred over correctly. Make sure you haven't forgotten a "yy++" somewhere, or access a grid like [yy, 0] instead of [0, yy] or something like that (I frequently make mistakes like this, haha). Let me know if that helps. If not, feel free to send me your project file and I can take a look! My e-mail is friendlycosmonaut@gmail.com.
FriendlyCosmonaut great thank you! It was in the script you mentioned and I put a "1" where a "i" should have been. Thank you and I look forward the next tutorial! :)
Yeah I'm just drawing the strings we input into the grid in the previous video. It might be that you either input empty strings, something in the "create_menu_page" script is wrong, or you're accessing the wrong "column" of the grid when it comes time to draw it
Sorry, for bothering! How about that project file. I'm trying to adopt the code for 1.4 but I his some roadblock and can't find why some errors pop up.
I watch your videos because your voice hahaa. You got an amazing voice for tutorials, I maybe copy some tips from you. My voice is terrible lol. Cool sliders!
Haha thank you! It's often said that we hate the sound of our own voices, so I'm sure it's just that way for you - I was always worried my voice was too "monotone". (Listening to one's own verbal ticks/mispronunciations during the editing process doesn't help either, haha.) I wouldn't let it stop you if you want to make tutorials. I think it's far more important to have clear explanations and fun/helpful ideas to teach others!
Hey! Loving every tutorial you put out. It helps me out a lot! If you ever feel like make more series like your Farming RPG one (where it's a series of tutorials based around one game concept) I got some suggestions for you: -A Mario Paint-esque game (could include a simple music maker, drawing program) I think I already suggested this one a bit earlier lol -Something 3D (A horror/adventure/fps game) -A game that incorporates the device's internal clock (think Animal Crossing, where accessibility of events, shops, and the day night cycle is based on the actual real life time & date.) These suggestions are mostly based on how available tutorials for them already are. Which varies from barely to none. And I have to say: like you did with the Farming RPG tutorial, presenting it immediately with the likeness of Stardew Valley was a great idea. It immediately makes the entire tutorial more familiar to your audience. Continuing to present your tutorials like that would really help your channel, I think. I hope my feedback/suggestions were the least bit useful and I hope your channel will continue growing!
Hey Cosmo, loving the vids again! Im stuck here. case menu_element_type.slider: var _len = 64; var _current_val = _ds_grid[# 3, _yy]; var _current_array = _ds_grid[# 4, _yy]; var _circle_pos = ((_current_val - _current_array[0]) / (_current_array[1] - _current_array[0])); _c = c_white;
draw_line_width(_rtx, _rty, _rtx +_len, _rty, 2); draw_circle_color(_rtx + (_circle_pos*_len), _rty, 4, _c,_c, false); draw_text_color(_rtx + (_len * 1.2), _rty, string(floor(_circle_pos*100))+"%", _c,_c,_c,_c, 1); break; When I go to graphics from the menu I get an error code saying DoSub :: Execution Engine - Cannot operate on string type at gml_Object_o_title_ui_Draw_64 (line 65) - var _circle_pos = ((_current_val - _current_array[0]) / (_current_array[1] - _current_array[0])); Also in the graphics tab earlier the diffrent resolution type's wouldn show. Been going over the vids a couple of times to check any misspeling. Any clue?
Hey, FriendlyCosmonaut, I love your videos and I have learned so much from them! Now I know I'm probably late to the party by about 2 years, but hopefully you could help me. I follow your tutorials pretty much to the letter but I still try my best to understand the content to apply to future games. I seem to have ran into a road bump, I can move on to the next page. I have taken a look at the other comments and have re watched your videos to see if I missed something but I can't find what I'm missing. Any suggestions?
Hello, I'm only 12 yrs old but your videos really help me in coding. P.S. What days do you post your videos and when will the next video on this be? Thank you for your time.
Thank you, that's wonderful that you're learning to code! I'm actually on holidays right now so it may be a little while. I also don't have an exact schedule for videos (there aren't particular days I publish them), so I apologise, but they're quite random!
MY god, it's like you've downed ten cans of red-bull, snorted some speed and having caffeine directly pumped into your blood. Can you try to slow down in future? I have to pause every few seconds just to try and catch up, and it's really frustrating.
And on top of that I have to then re-watch the video just to understand what you were talking about (to learn) as I spent the previous viewing trying to catch up and pausing every few seconds. Amazing videos, but not everyone can type at your ultra-fast, caffeine induced pace :/
Hey Peter - haha, I understand your frustration here. Please know that I actually fully anticipate that all my viewers are going to have to regularly pause the video, not only to write in the code, but to hopefully also think about what they're writing. That's always what I did/expected when I was starting out and also learning tutorials. I try and record/edit my videos so that they go at a fairly fast pace, just so I can squeeze in enough content as possible (my videos tend to be 10-30 minutes as it is). Also, this series covers some advanced topics that may not be beginner friendly if you aren't familiar with the concepts like arrays and data structures - I assume a bit of knowledge and so don't always stop to explain those concepts. Unfortunately we all have our different preferences/learning styles, and I can't make everyone happy :(! But I'll keep your feedback in mind going forward and keep an eye out in case a lot of other viewers feel the same.
This has to be the most in depth, structured and still short tutorial series on the internet. Very well done! I really like yourr planning and tidy approach to things.
@@pupaproductions4784 yes, it did work on the first try if I remember correctly. What doesn't work for you exactly?
You’re the best GM teacher on UA-cam by far. I’ve made my own menu systems, but after watching this tutorial I;m wishing I;d watched this first!
Yeah, after finding this series I've decided on rebuilding my menus from scratch.
i agree a lot, beside she coding very well she also explain very very well
Just wanted to pop in and say THANK YOU! Your videos are incredibly useful, and so very easy to understand. If I ever need help with a new system, you're my first stop, because I know that if you explain something, I'll understand it.
Your help has been invaluable in developing my first game, so I'm happy to say thanks by signing up as a patron! Please keep up the awesome work!
Thanks so much, Jamie! I'm thrilled to hear that. I'd love to see what you're working on, if you're getting to a stage where you can show off your work! Feel free to @FCosmonaut on twitter anytime! :)
This is on a whole new level! Just when I thought I was a decent coder I realize I know nothing!!! :) Absolutely brilliant @FriendlyCosmonaut!!!! Brilliant!
this whole series really helped teach me how to organize data--I had really messy code and this helped clean it right up! ty so much!
Absolutely lovely series of tutorial. Just really, thank you for your work, these systems are perfect and are nice modules that can be inserted anywhere without changing every line of code.
CANNOT WAIT FOR THE NEXT ONE! GREAT WORK MY FRIEND! Super helpful and inspirational!
This channel is a treasure trove of game maker tutorials.
I am the globgogabgolab, this is my true treasure trove
Youre my favorite tutorial instructor right now.. Thanks so much, these are great
Brilliant!! I swapped out the Draw Circle for Draw Sprite, and Added a Shurikan as the slider handle..Also, this is great coding, it plugged straight into my Game, as is, with no messing, just a couple of variable names changed.
Omg you are so in a hurry lol! Great tutorial though, you really inspired me to be cleaner with my code because I feel like you are in another level of code management xD
Yeah I think I rushed through a couple of these videos too quick. I'm going to leave a bit more time for the typing segments in future videos :). But thanks!
Yeah at 19:00 I get an error "illegal array use". It's because of the line: current_array[current_val]
No matter what I do, it crashes with that code. Please help? :)
Found it.. forgot to declare the 4th column in my create>graphics
@@zenomexican7179 its always some fucking shit lol
Thank you so much for the tutorials. I just went ahead and downloaded Game Maker because of your videos.
That's awesome! I hope you enjoy it.
good tutorial! But I'd just like to mention that using "if(!global.pause) exit;" causes the an error saying it has exited with a non-zero status
I can't activate the last "back". It's never going out of the settings page
hey the "var circle_pos ((current_val - current_array[1]) / current_array[1] - current_array[0]" doesn't work! can anyone tell me an alternate way to write that line?
I had the same problem, it was because the 'var circle_position' was declared before the 'var current_array'.
Also, in your comment you didn't put the '=' between var circle_pos and the operations, i don't know if you put it in the code tho.
Love this video, but I've noticed we don't get to check for errors until quite a bit into the video. It would be awesome to test the code as it's written so I know I'm following along.
Thanks so much for this short video series❤ Most menu tutorials aren't great so this is godsend 🙏
When i press enter it does not switch the page... I think I've looked over all my code, everything is the same as yours. What is the problem here???
i fixed the problem. i misspelled the page variable
Trial and error checking the buffer settings as per the font you wish to use, any ideas on how to implement spacing of text thats more flexible?
@@pupaproductions4784 method?
this being? or am i using? drugs? HELP for COMPREHENSION. i am slow learner and bad at following#mywalls
yea, i wrote a better method. I can assist you but I do not know you yet, we can talk
@@pupaproductions4784 detail i sea. READ i did. You may speak with me computer or human. COMPLY?
@@pupaproductions4784 i know the fear of closing spaces friend! speak freely to me and me can help!!!red speech knows how to FLAG nor FAIL...SERIOUSLY humans.
@@LspRevenge this fr looks like you're talking to yourself lmao
Hello! I really want sprites to replace the text, is there any way to do that? I have tried to do this in many hours now! please help me
|
Seven months late, but you should learn how drawing sprites works. The origion of your sprites need to fit the draw position. It's pretty simple once you understand how sprites work :)
strings wont add together for some reason.
Any plans on making this menu mouse controlled also? I am having a hard time making a menu that’s mouse controlled and would love to see how it’s done
Ah, I could probably do this in a future one! It might be a ways off though: if you're keen to look into it now, I'd suggest using the device_mouse_y_to_gui() to get the mouse position. Then to check which "element" the mouse is selecting, when we loop through and draw all the elements, you could see if the mouse is near the y position of the one we're currently drawing. (By near, you could check if it's within y_buffer/2 up or down). If it is, then set the selection to that element.
i have a question do you maybe know how to make a slide bar mouse controlled with like a rectangle collision i just don't know how to make a simple not complex check for mouse sliding so if the mouse slides to left then slide to left
my suggestion for a basic system would be to check the mouses position to make sure that you are "in range" of the element. Then check for a mouse button down event using mouse_check_button_pressed(mb_left).
While the mouse button is clicked, i would make the pointer invisible, using window_set_cursor(cr_none), and set a variable to store your mouse x position at the time of clicking.
Then check the current mouse x position and move your slider accordingly, probably based off a percentage of the size of your gui.
Once the mouse_down event is over, make your cursor visible, and make sure you are set for new inputs for normal menu operation.
@@FriendlyCosmonaut I’m sorry that I’m writing this so late but I’ve been having extreme trouble getting anything be affected by the mouse. I’ve used both the y_buffer and device_mouse_y_to_gui but to no avail. Plz help, sorry for this being years after the video was posted, and thx for the video it was overall super helpful
Two questions
I am having a lot of trouble understanding why people use the "var" word in front of the variable, as opposed to leaving it off?
Also, why bother assigning another variable to things, such as gwidth = gobal.view_width. Can't you just use global.view_width, directly in the function itself, instead of asking for gwidth, which points back at global.view_width?
Is this for readability, or does this serve a performance purpose, or both?
thanks!
Its kind of both.
Why they use ”var” in front of a variable is a way of asigning a variable that will be removed when the game updated.
Theyre also a little faster than normal variables.
Dang, all the text displays on the screen "resume, settings, exit" but its all squished together on the width and the height. Maybe I need to try setting the global.view_width to display_get_width() instead I will post if this solves it or makes it worse.
Well I figured out that the view_height was set to camera "width" and vice versa which is why it was squished looking. Now the test simply is just small but not squished looking anymore.
This is an awesome idea, but I have one question. When you go from page to page, it remembers what option you were on for that page. How do I get it so it resets back to the first choice when you go back to a page?
I keep getting "Data Structure with index does not exist" in the draw gui event where im initializing the ds_height to ds_grid_height(ds_grid), ds_grid being set to menu_pages[page].
I had to do my create event slightly differently because I'm using Game Maker Studio 1.x so I couldn't initialize the array in the same way. Otherwise they're identical as far as I can see.
title_music = sndTitle;
// Title music for my game, ignore.
global.multiplayer = false;
// Multiplayer mode for my game, ignore.
pause = true;
view_width = view_wview[0];
view_height = view_hview[0];
display_set_gui_size(view_width, view_height);
enum menu_page
{
main,
settings,
audio,
graphics,
controls,
height
}
enum menu_element_type
{
script_runner,
page_transfer,
slider,
shift,
toggle,
input
}
// Create Menu Pages:
// *NOTE* here I could not use the brackets around each parameter like in the tutorial,
// For whatever reason that doesn't work in 1.x, but I feel like that shouldn't matter.
ds_menu_main = create_menu_page
(
"RESUME", menu_element_type.script_runner, resume_game,
"SETTINGS", menu_element_type.page_transfer, menu_page.settings,
"EXIT", menu_element_type.script_runner, exit_game
);
ds_settings = create_menu_page
(
"AUDIO", menu_element_type.page_transfer, menu_page.audio,
"GRAPHICS", menu_element_type.page_transfer, menu_page.graphics ,
"CONTROLS", menu_element_type.page_transfer, menu_page.controls ,
"BACK", menu_element_type.page_transfer, menu_page.main
);
ds_menu_audio = create_menu_page
(
"MASTER", menu_element_type.slider, change_volume, 1, 0,1 ,
"SOUNDS", menu_element_type.slider, change_volume, 1, 0,1 ,
"MUSIC", menu_element_type.slider, change_volume, 1, 0,1 ,
"BACK", menu_element_type.page_transfer, menu_page.settings
);
ds_menu_graphics = create_menu_page
(
"RESOLUTION", menu_element_type.shift, change_resolution, 0, "640 x 360", "1280 x 720","1920 x 1080" ,
"WINDOW MODE", menu_element_type.toggle,change_window_mode, 1, "FULLSCREEN","WINDOWED" ,
"BACK", menu_element_type.page_transfer, menu_page.settings
);
/*
I did not want to use controls yet, which is why this is commented out.
ds_menu_controls = create_menu_page
(
"UP", menu_element_type.input, "up", gp_padu ,
"DOWN", menu_element_type.input, "down", gp_padd ,
"RIGHT", menu_element_type.input, "right", gp_padr ,
"LEFT", menu_element_type.input, "left", gp_padl ,
"BACK", menu_element_type.page_transfer, menu_page.settings
);
*/
// This is where I'm initializing the menu_pages array. I had to assign each value individually because of 1.x.
// again, I feel like this should definitely still work.
page = 0;
menu_pages[0] = ds_menu_main;
menu_pages[1] = ds_settings;
menu_pages[2] = ds_menu_audio;
menu_pages[3] = ds_menu_graphics;
var i = 0, array_len = array_length_1d(menu_pages);
repeat (array_len)
{
menu_option[i] = 0;
i++;
}
//Just in case that actually does all check out as I suspect it most likely does,
//here's my create_menu_page() script.
/// create_menu_page("Name", type, entries...)
var arg, i = 0;
repeat (argument_count)
{
arg[i] = argument[i];
i++;
}
var ds_grid_id = ds_grid_create(5, argument_count);
i = 0;
repeat (argument_count)
{
var array = arg[i];
var array_len = array_length_1d(array);
var xx = 0;
repeat (array_len)
{
ds_grid_id[# xx, i] = array[xx];
xx++;
}
i++;
}
return ds_grid_id;
// Everything above is exactly the same as in the tutorial, besides the fact that I decided not to use difficulty and controls for now.
Thank you so much in advance to anyone who is able to fix this issue for me. I'm trying to use this system for a game I intend on putting on Steam as my first actual release, so a quick response would be greatly appreciated!
i hope you eventually managed to fix your project, but i just wanted to say thank you cos you helped me fix the issue of mine not being able to move past my audio/difficulty/resolution/exit page. i hadnt declared what each individual page was in an array like below (menu_pages[0] etc) and i forgot the i++; at the end lol
page = 0;
menu_pages[0] = ds_menu_main;
menu_pages[1] = ds_settings;
menu_pages[2] = ds_menu_audio;
menu_pages[3] = ds_menu_graphics;
var i = 0, array_len = array_length_1d(menu_pages);
repeat (array_len)
{
menu_option[i] = 0;
i++;
}
So i just did the slider part, but it only draws the top one? any reason that would be happening?
Hey! I'm having the same issue (one year later), did you ever find the cause for it?
Actually, I just figured it out! I forgot to add 1 to yy at the end of the loop
oh no i have the same issue.... and yes the issue was that small yy++ at the end that i missed
can somone please help me? I can select the "settings" option from the main menu but then after that I can't go back, as I can't interact with the back option or any other options.
edit: I realize now its just skipping over to the audio page and completely avoiding the settings, still need some help figuring it out-
edit2: Figured it out after a bit of me having an existencial crisis lol, apparently the order of the menu_pages variable DO matter, for example:
menu_pages = [ds_menu mian, ds_settings, ds_audio, etc etc] would be correct and take you in order, but if its out of order it'll place you in witchever comes first- like if you siwtched settings and audio, it'll take you to audio when you press settings etc-
I have problems when I start doing the right side. Having registered the code for DIFFICULTY, I launch the game to check, and when I go to the DIFFICULTY section, an error appears:
"trying to index a variable which is not an array"
draw_text_color (rtx, rty, left_shift + current_array [current_val] + right_shift, c, c, c, c, 1);
As I understand it, the problem is in "current_array [current_val]"
The same problem is in the AUDIO section.
If something is missing from me, the GRAPHICS section in CONTROLS is because they are not needed in my game.
Thanks.
I find error i Step)
im having a problem. whenever i press the button to go to the next page it brings me to audio, but when i commented out audio it brought me to people. so its just skipping over the settings. PLEASE HELP
The "index" of each page is just set by their order in the data structure. You're probably just telling it to go to the wrong "number" page, so I'd suggest just carefully combing through the code and making sure everything is set correctly. If everything looks fine there, then it might be a problem with how you've set the data structure up (check in debug mode if the order of everything in the data structure is what you expect it to look like)
FriendlyCosmonaut ok I will try that
I was having the same issue as this person. I had set up my menu_page enum like so:
enum menu_page {
main,
play,
settings,
audio,
graphics,
controls,
height //to grab # of entries in enumerator
}
However, I realized "play" isn't actually a page (in my case it'll execute code taking the game to another room), and when I got rid of it, my menus started working correctly.
Hey FriendlyCosmonaut! I got one problem with circles in the sound menu.
They appear much further (to the right) from the lines. Are there any solutions? (I watched the video several time but couldn't figure out what's wrong).
I'm having a problem with this I put the code in as you said but upon booting the game it says this:
draw_text_color(rtx,rty,left_shift+current_array[current_val]+right_shift,c,c,c,c,1);
is an illegal use of an array but it shouldn't be.
Anyone know a fix for this?
Hey can anyone tell me how you would set up the slider without the slider bar and just the val%?
i guess get rid of draw_line_width and draw_circle_color
and write draw_text_color(rtx,rty,…,c,c,c,c,1);
Instead of the three dots just put what was on the tutorial
Upon following this video, everything works except for when I press enter on a page_transfer element; it just doesn't change pages. I rewatched the video and compared my code to the video in every script and it matches, but it still doesn't change pages. I am so lost please let me know if you can help ♥
Edit:
After sleeping and getting back on, I still am not able to figure it out... Here's my code.
// Menu Create
global.pause = true;
global.view_width = camera_get_view_width(view_camera[0]);
global.view_height = camera_get_view_height(view_camera[0]);
//global.key_revert = ord("X");
global.key_enter = vk_enter;
//global.key_left = vk_left;
//global.key_right = vk_right;
global.key_up = vk_up;
global.key_down = vk_down;
display_set_gui_size(global.view_width, global.view_height);
enum menu_page {
main = 0,
settings = 1,
audio = 2,
difficulty = 3,
graphics = 4,
controls = 5,
height
}
enum menu_element_type {
script_runner = 0,
page_transfer = 1,
slider = 2,
shift = 3,
toggle = 4,
input = 5
}
// Create Menu Pages
ds_menu_main = create_menu_page(
["RESUME", menu_element_type.script_runner, resume_game],
["SETTINGS", menu_element_type.page_transfer, menu_page.settings],
["EXIT", menu_element_type.script_runner, exit_game],
);
ds_settings = create_menu_page(
["AUDIO", menu_element_type.page_transfer, menu_page.audio],
["DIFFICULTY", menu_element_type.page_transfer, menu_page.difficulty],
["GRAPHICS", menu_element_type.page_transfer, menu_page.graphics],
["CONTROLS", menu_element_type.page_transfer, menu_page.controls],
["BACK", menu_element_type.page_transfer, menu_page.main],
);
ds_menu_audio = create_menu_page(
["MASTER", menu_element_type.slider, change_volume, 1, [0,1]],
["SOUNDS", menu_element_type.slider, change_volume, 1, [0,1]],
["MUSIC", menu_element_type.slider, change_volume, 1, [0,1]],
["BACK", menu_element_type.page_transfer, menu_page.settings],
);
ds_menu_difficulty = create_menu_page(
["ENEMIES", menu_element_type.shift, change_difficulty, 0, ["HARMLESS","NORMAL","TOUGH"]],
["PROGRESSION", menu_element_type.shift, change_difficulty, 0, ["LOW","MEDIUM","HIGH"]],
["BACK", menu_element_type.page_transfer, menu_page.settings],
);
ds_menu_graphics = create_menu_page(
["RESOLUTION", menu_element_type.shift, change_resolution, 0, ["640 x 480","1080 x 720","1920 x 1080","2560 x 1440","3840 x 2160"]],
["WINDOW MODE", menu_element_type.toggle, change_window_mode, 1, ["FULLSCREEN","WINDOWED"]],
["BACK", menu_element_type.page_transfer, menu_page.settings],
);
ds_menu_controls = create_menu_page(
["UP", menu_element_type.input, "key_up", vk_up],
["DOWN", menu_element_type.input, "key_down", vk_down],
["LEFT", menu_element_type.input, "key_left", vk_left],
["RIGHT", menu_element_type.input, "key_right", vk_right],
["USE", menu_element_type.input, "key_use", ord("E")],
["ABILITY", menu_element_type.input, "key_ability", ord("F")],
["BACK", menu_element_type.page_transfer, menu_page.settings],
);
page = 0;
menu_pages = [ds_menu_main, ds_settings, ds_menu_audio, ds_menu_difficulty, ds_menu_graphics, ds_menu_controls];
var arr_len = array_length_1d(menu_pages);
for (var i = 0; i < arr_len; i++) {
menu_option[i] = 0;
}
// Menu Step
if (global.pause == true) {
input_up_p = keyboard_check_pressed(global.key_up);
input_down_p = keyboard_check_pressed(global.key_down);
input_enter_p = keyboard_check_pressed(global.key_enter);
var ds_grid = menu_pages[page];
var ds_height = ds_grid_height(ds_grid);
var ochange = input_down_p - input_up_p;
if (ochange != 0) {
menu_option[page] += ochange;
if (menu_option[page] > ds_height - 1) {
menu_option[page] = 0;
}
if (menu_option[page] < 0) {
menu_option[page] = ds_height - 1;
}
}
if (input_enter_p) {
draw_text(10, 10, "1");
switch(ds_grid[# 1, menu_option[page]]) {
case menu_element_type.page_transfer: page = ds_grid[# 2, menu_option[page]]; break;
}
} else {
var newCol = c_white;
draw_text_colour(10, 10, "0", newCol, newCol, newCol, newCol, 1);
}
}
// create_menu_page() script
function create_menu_page() {
var arg;
for (var i = 0; i < argument_count; i++) {
arg[i] = argument[i];
}
var ds_grid_id = ds_grid_create(5, argument_count);
for (var i = 0; i < argument_count; i++) {
var arr = arg[i];
var arr_len = array_length_1d(arr);
for (var xx = 0; xx < arr_len; xx++) {
ds_grid_id[# xx, i] = arr[xx];
xx++
}
}
return ds_grid_id;
}
Thanks in advance!
Update: I figured out what the problem is but still am unable to find a remedy. Basically, upon creation of the menu, the menu_element_type.script_runner, menu_element_type.page_transfer, etc. are not being properly assigned in the create event
Example:
// Create Event
enum menu_element_type {
script_runner,
page_transfer,
slider,
shift,
toggle,
input
}
// Create Menu Pages
ds_menu_main = create_menu_page(
["RESUME", menu_element_type.script_runner, resume_game],
... etc.
every single value where menu_element_type.script_runner is, is just being set to 0 even when I put page_transfer which I found out through the debugger.
Debugger:
ds_menu_main > 1 > 0 = 0, 1 = 0, 2 = 0
screenshots:
imgur.com/a/z4AkkmL
and
imgur.com/a/VYdJ8mN
update, after a total of 18 hours of headbanging on the wall, I have found the solution. In my menu_create_page script, I had
for (var xx = 0; xx < arr_len; x++) {
ds_grid_id[# xx, I] = arr[xx];
xx++;
} // Because I prefer for loops rather than repeat loops.
but I forgot to remove the xx++;
Another issue was in the Draw GUI Event in the Menu Object, where I had
for (var yy = 0; yy < ds_height; yy++) {
// I forgot to add the rty = start_y + (yy * y_buffer); so it was returning a read before set error.
switch().... etc.
}
Hope this helps anyone with the same or similar error!
What font is that? It's hard to find ones that I like for pixelated games.
It's Fixedsys Excelsior - a free font :)
Thank you!
@@FriendlyCosmonaut How are you assigning the font? i didnt see this in the video and my text is so small maybe it could be related to this?
I cannot seem to find where you mentioned it. . .but what does the '#' mean when you call it here ds_grid[# 1,yy]? I understand that the ds_grid is essentially a 2d array; and that the '1' is the x-coordinate where the 'yy' is the y-coordinate, but don't get the '#'.
So these are called "accessors" - they're different for every data structure type. The grids use "#", while ds_lists use "|", and ds_maps use "?". It's quite arbitrary. But basically, they're just a "quick way" to get access to a grid. There are actually functions that will do the same thing:
ds_grid_get(index, x cell position, y cell position); //gets the value a cell holds
ds_grid_set(index, x cell position, y cell position, value); //sets a cell equal to a value
But instead of using those, you can just write
value = ds_grid[# cell_x, cell_y];
ds_grid[# cell_x, cell_y] = value;
So think of it like a shortcut!
when I typed in the code and did the test the menu did not show up on the test run...
What should I do???
Did you put the object in the room?
I get an error on the 3rd row of the step event. It's not shown with a typical red warning, yet when I start the game, it crashes and keeps bringing up this line. It looks EXACTLY as you typed it though. :(
Nevermind! I went back under create and realized that I set ALL the keys as "revert"! Silly me! ;P
Great work on solving it :)!
it only took my sanity
Can i get your source code please.. NO matter which option i chose audio,difficulty or graphics all of them draws the same exact strings "Master","Sound","Music","back". I just did exactly as you did but dont know where the error is.
Problem solved all my Data in ds_setting has same menu_page.audio.. ha ha
Hehe, nice job on the solve :)
Great tutorial!
My options texts only shows "SETTINGS", "SETTINGS", "SETTINGS" instead of "RESUME", "SETTINGS", "EXIT". Everything else works like it will goto the settings menu but the same problems remains, it only shows one of the menu names and just repeats them. Im not sure where I messed up at but the draw event I have is:
//Draw elements on left side
draw_set_valign(fa_middle);
draw_set_halign(fa_right);
var ltx = start_x - x_buffer, lty, xo;
var yy = 0; repeat ds_height {
lty = start_y + (yy*y_buffer);
c = c_white;
xo = 0;
if yy == menu_option[page] {
c = c_orange;
xo = -(x_buffer/2);
}
draw_text_color(ltx+xo, lty, ds_grid[# 0,yy], c,c,c,c,1);
yy++;
}
Any idea where I made my error or maybe I made the error somewhere else?
Sorry for the late reply (I'm still on holidays!). Hmm, can you check the content of the grid in the debugger (as I show in the previous video) and see if the strings are correct there? If they're not, that means the problem would actually be where you STORE the data for the strings, ie. in the create_menu_page script. I'd look in the loop and ensure that the arrays are being transferred over correctly. Make sure you haven't forgotten a "yy++" somewhere, or access a grid like [yy, 0] instead of [0, yy] or something like that (I frequently make mistakes like this, haha).
Let me know if that helps. If not, feel free to send me your project file and I can take a look! My e-mail is friendlycosmonaut@gmail.com.
FriendlyCosmonaut great thank you! It was in the script you mentioned and I put a "1" where a "i" should have been. Thank you and I look forward the next tutorial! :)
Ahh, well done! I do things like that all the time.
Where do you put the actual "menus" I mean the graphical component. Is it a sprite? Or are raw strings? I have only 3 zeroes.
Thank you.
Yeah I'm just drawing the strings we input into the grid in the previous video. It might be that you either input empty strings, something in the "create_menu_page" script is wrong, or you're accessing the wrong "column" of the grid when it comes time to draw it
Does this work in GMS2.3?
seems to be working so far but my text is too small! idk if this is related to the GM version or operator error.
These tutorials are awesome! Could you upload the files as a template we can use?
Sorry for the late reply - I've been away for a bit but will upload a file when I'm back at my desktop.
Sorry, for bothering! How about that project file. I'm trying to adopt the code for 1.4 but I his some roadblock and can't find why some errors pop up.
I watch your videos because your voice hahaa. You got an amazing voice for tutorials, I maybe copy some tips from you. My voice is terrible lol. Cool sliders!
Haha thank you! It's often said that we hate the sound of our own voices, so I'm sure it's just that way for you - I was always worried my voice was too "monotone". (Listening to one's own verbal ticks/mispronunciations during the editing process doesn't help either, haha.) I wouldn't let it stop you if you want to make tutorials. I think it's far more important to have clear explanations and fun/helpful ideas to teach others!
Why is my text so much smaller!!!?
Hey!
Loving every tutorial you put out. It helps me out a lot!
If you ever feel like make more series like your Farming RPG one (where it's a series of tutorials based around one game concept) I got some suggestions for you:
-A Mario Paint-esque game (could include a simple music maker, drawing program) I think I already suggested this one a bit earlier lol
-Something 3D (A horror/adventure/fps game)
-A game that incorporates the device's internal clock (think Animal Crossing, where accessibility of events, shops, and the day night cycle is based on the actual real life time & date.)
These suggestions are mostly based on how available tutorials for them already are. Which varies from barely to none.
And I have to say: like you did with the Farming RPG tutorial, presenting it immediately with the likeness of Stardew Valley was a great idea. It immediately makes the entire tutorial more familiar to your audience. Continuing to present your tutorials like that would really help your channel, I think.
I hope my feedback/suggestions were the least bit useful and I hope your channel will continue growing!
Hey, thank you! Ah, awesome, these are great suggestions. It's going to be so hard to choose which direction to go in when I jump into a new series :)
Hey Cosmo, loving the vids again! Im stuck here.
case menu_element_type.slider:
var _len = 64;
var _current_val = _ds_grid[# 3, _yy];
var _current_array = _ds_grid[# 4, _yy];
var _circle_pos = ((_current_val - _current_array[0]) / (_current_array[1] - _current_array[0]));
_c = c_white;
draw_line_width(_rtx, _rty, _rtx +_len, _rty, 2);
draw_circle_color(_rtx + (_circle_pos*_len), _rty, 4, _c,_c, false);
draw_text_color(_rtx + (_len * 1.2), _rty, string(floor(_circle_pos*100))+"%", _c,_c,_c,_c, 1);
break;
When I go to graphics from the menu I get an error code saying
DoSub :: Execution Engine - Cannot operate on string type
at gml_Object_o_title_ui_Draw_64 (line 65) - var _circle_pos = ((_current_val - _current_array[0]) / (_current_array[1] - _current_array[0]));
Also in the graphics tab earlier the diffrent resolution type's wouldn show. Been going over the vids a couple of times to check any misspeling.
Any clue?
Fixed it! It seems in the Create event I had the Menu_element_type on a .slider instead of .shift
Hey, FriendlyCosmonaut, I love your videos and I have learned so much from them! Now I know I'm probably late to the party by about 2 years, but hopefully you could help me. I follow your tutorials pretty much to the letter but I still try my best to understand the content to apply to future games. I seem to have ran into a road bump, I can move on to the next page. I have taken a look at the other comments and have re watched your videos to see if I missed something but I can't find what I'm missing. Any suggestions?
Sorry, I can't move on to the next page
Fucking awesome thank you sooo much
Thank you!
Thanks boss.
1:58
Hello, I'm only 12 yrs old but your videos really help me in coding. P.S. What days do you post your videos and when will the next video on this be? Thank you for your time.
Thank you, that's wonderful that you're learning to code! I'm actually on holidays right now so it may be a little while. I also don't have an exact schedule for videos (there aren't particular days I publish them), so I apologise, but they're quite random!
Thanks for the info. Merry X-mas : )
Veeery cool!
i feel like im in school.. cos i dont understand anything ur saying and just copy pasting it in my brain
Slow down!
I agree, a Little Slower so we can Absorb the meaning of the code
MY god, it's like you've downed ten cans of red-bull, snorted some speed and having caffeine directly pumped into your blood. Can you try to slow down in future? I have to pause every few seconds just to try and catch up, and it's really frustrating.
And on top of that I have to then re-watch the video just to understand what you were talking about (to learn) as I spent the previous viewing trying to catch up and pausing every few seconds. Amazing videos, but not everyone can type at your ultra-fast, caffeine induced pace :/
Hey Peter - haha, I understand your frustration here. Please know that I actually fully anticipate that all my viewers are going to have to regularly pause the video, not only to write in the code, but to hopefully also think about what they're writing. That's always what I did/expected when I was starting out and also learning tutorials.
I try and record/edit my videos so that they go at a fairly fast pace, just so I can squeeze in enough content as possible (my videos tend to be 10-30 minutes as it is). Also, this series covers some advanced topics that may not be beginner friendly if you aren't familiar with the concepts like arrays and data structures - I assume a bit of knowledge and so don't always stop to explain those concepts. Unfortunately we all have our different preferences/learning styles, and I can't make everyone happy :(! But I'll keep your feedback in mind going forward and keep an eye out in case a lot of other viewers feel the same.