Skip to content

Instantly share code, notes, and snippets.

@pixelage
Last active May 17, 2023 11:56
Show Gist options
  • Save pixelage/ad01af8724473964b788dac4a944d3fb to your computer and use it in GitHub Desktop.
Save pixelage/ad01af8724473964b788dac4a944d3fb to your computer and use it in GitHub Desktop.
[Game Menu 01] Basic game menu nothing fancy #gml #gms2 #menu
menu_x = x;
menu_y = y;
button_h = 32;
button[0] = "New Game";
button[1] = "Load Game";
button[2] = "Options";
button[3] = "Exit Game";
buttons = array_length_1d(button);
menu_index = 0;
last_selected = 0;
var i = 0;
repeat (buttons) {
draw_set_font(ft_main);
draw_set_halign(fa_center);
draw_set_colour(c_ltgray);
if (menu_index == i) draw_set_colour(c_red);
draw_text(menu_x, menu_y + button_h * i, button[i]);
i++;
}
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(sd_menuswitch,1,false);
last_selected = menu_index;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment