• 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!

Legacy GM [NEED HELP!!!] PAUSE MENU

I

Isaiah Reyes

Guest
Thanks for looking, I have this code for a pause menu for 4 options: The "{# #}" Just represents the code group as a whole when I copied and pasted them. I am only getting 3 of the four options to show.






Create:
{#
/// Initialize the menu
title = "Game Paused";

option[0] = "Return";
option[1] = "Save";
option[2] = "Load";
Option[3] = "Quit";

// Menu Index
menu_index = 0;
#}









then I have my alarm but its just basic since I am using a game controller as well

after that I have a STEP event:









{#
/// Control the menu
if (alarm[0] <= 0) {
if (obj_input.down_key) {
if (menu_index < array_length_1d(option)-1) {
menu_index++;
} else {
menu_index = 0;
}
alarm[0] = room_speed/6;
}

if (obj_input.up_key) {
if (menu_index > 0) {
menu_index--;
} else {
menu_index = array_length_1d(option)-1;
}
alarm[0] = room_speed/6;
}
}
#}







after that I have a DRAW GUI event:





{#
/// Draw the menu
var xx = display_get_gui_width()/2;
var yy = display_get_gui_height()/2;
draw_set_halign(fa_center);
draw_text(xx, yy-64, title);

for (var i=0; i<=array_length_1d(option)-1; i++) {
draw_set_colour(c_gray);
if (i == menu_index) {
draw_set_colour(c_white);
}
draw_text(xx, yy+(i*32), option);
}
draw_set_colour(c_white);
draw_set_halign(fa_left);
#}
 
Last edited by a moderator:

TheouAegis

Member
You capitalized Option[3].

Nitpick:
i<=array_length_1d(option)-1;
<= is slower than < and subtracting 1 is slower than doing nothing. Just use
i < array_length_1d(option);

Also with for loops, your break condition should be a simpke variable check, not a function or script call, since it will run that function on every iteration.

draw_set_colour(c_gray);
if (i == menu_index) {
draw_set_colour(c_white);

Swap the order around with an else so you only set the color once, like so:

if (i == menu_index)
draw_set_colour(c_white);
else
draw_set_colour(c_gray);
 
Last edited:
option[0] = "Return";
option[1] = "Save";
option[2] = "Load";
Option[3] = "Quit";

option and Option are two different variables. Get rid of the capitalisation in the last option.
 
I

Isaiah Reyes

Guest
You capitalized Option[3].

Nitpick:


<= is slower than < and subtracting 1 is slower than doing nothing. Just use
i < array_length_1d(option);

Also with for loops, your break condition should be a simpke variable check, not a function or script call, since it will run that function on every iteration.

draw_set_colour(c_gray);
if (i == menu_index) {
draw_set_colour(c_white);

Swap the order around with an else so you only set the color once, like so:

if (i == menu_index)
draw_set_colour(c_white);
else
draw_set_colour(c_gray);

That's pretty cool, thanks for showing me a much more simpler way!!!
 
I

Isaiah Reyes

Guest
option[0] = "Return";
option[1] = "Save";
option[2] = "Load";
Option[3] = "Quit";

option and Option are two different variables. Get rid of the capitalisation in the last option.


Thanks lol I've been looking at this for 2 hours I gave up but I didn't notice the capital. I forget how fast you can mess yourself up with even the tiniest thing.
 
Top