• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] Text Menus Sub Menu

C

CRob1974

Guest
Hi,
I have been trying to create a text menu in GM2 and I now understand the following tutorial:


I would now very much like to create sub menus / links. For example: Options would lead to Display, Sound & Controls. At the moment it just shows a show_debug_message

Is there any way of doing it using 1 Control Object & 1 Room?

I have achieved this by transitioning with room_goto() and creating a new obj_control (placed in a new room) but this seems very long winded.

Thank you

PS. I dont expect you to watch the whole video, so here is the code from Code Workshop (not my code)

Code:
//Create
menu_x = x;
menu_y = y;
button_h = 32;
button[0] = "New Game";
button[1] = "Load Game";
button[2] = "Options";
button[3] = "Exit";
buttons = array_length_1d(button);
menu_index = 0;
last_selected = 0;

//Step
menu_move = keyboard_check_pressed(vk_down) - keyboard_check_pressed(vk_up);
menu_index += menu_move;
if (menu_index < 0) menu_index = buttons - 1;
if (menu_index > buttons - 1) menu_index = 0;
if (menu_index != last_selected) audio_play_sound(snd_menu_switch, 1, false);
last_selected = menu_index;

//Draw
var i = 0;
draw_set_font(font_main);
draw_set_halign(fa_center);
draw_set_color(c_ltgray);
repeat(buttons) {
    draw_set_color(c_ltgray);
    if (menu_index == i) draw_set_color(c_red);
    draw_text(menu_x, menu_y + button_h * i, button[i]);
    i++;
}

//Key Press Enter
switch(menu_index) {
    case 0:
        show_debug_message("NEW MENU");
        break;
    case 3:
        game_end();
        break;
}
 
Last edited by a moderator:
H

Homunculus

Guest
Friendly Cosmonaut has a series of tutorials on menus with variable depth and branches:

I know you already started coding based on another tutorial, but the tutorials above might still give you an idea on how to extend your code without rewriting everything.
 
C

CRob1974

Guest
Friendly Cosmonaut has a series of tutorials on menus with variable depth and branches:

I know you already started coding based on another tutorial, but the tutorials above might still give you an idea on how to extend your code without rewriting everything.
Thanks for the reply. Although I have been coding using another tutorial if someone finds something better that I have overlooked then all the better. I will start the tutorial tomorrow and let you know how I get on. Thanks again.
 
C

CRob1974

Guest
OK, just tried it and although it works its a very long bit of code for doing a simple task like this. All I want is a few options in text that lead to another few options in text. Surely a powerful program like gamemaker could do that with its eyes shut. You could do this on the zx spectrum in just a few lines of code. One good thing though, I didnt understand ds_lists before, now I do :)
 

Fabseven

Member
OK, just tried it and although it works its a very long bit of code for doing a simple task like this. All I want is a few options in text that lead to another few options in text. Surely a powerful program like gamemaker could do that with its eyes shut. You could do this on the zx spectrum in just a few lines of code. One good thing though, I didnt understand ds_lists before, now I do :)
For me all gui things are no existant in gmaker, you have to draw your buttons and others things.
The same goes for menu and submenu , i managed to do a menu/submenu code in the past
I used 1 array (2d) to do it, in the beginning with a script menu_init i fill the array with the "front" menu (new game,load game,options, exit) and when you click on a option, let's says "options" a script menu_options is launched and i fill the array again with others things , in the end if a button is going to a "no menu" windows i can still use another code to do the trick.

In the end i think gmaker is very powerfull to handle obj behaviour in the draw layout BUT for gui you have to do most of the work (witch is very long)
 
C

CRob1974

Guest
For me all gui things are no existant in gmaker, you have to draw your buttons and others things.
The same goes for menu and submenu , i managed to do a menu/submenu code in the past
I used 1 array (2d) to do it, in the beginning with a script menu_init i fill the array with the "front" menu (new game,load game,options, exit) and when you click on a option, let's says "options" a script menu_options is launched and i fill the array again with others things , in the end if a button is going to a "no menu" windows i can still use another code to do the trick.

In the end i think gmaker is very powerfull to handle obj behaviour in the draw layout BUT for gui you have to do most of the work (witch is very long)
Yes I agree. I think I will go back to what you said about drawing buttons and make it look like a text menu.
 
Top