Last active
May 17, 2023 11:56
-
-
Save pixelage/e026bbeb1b0ebd154e1c9bf461ba8c48 to your computer and use it in GitHub Desktop.
[Game Menu 02]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Basic Variables | |
menu_x = x; | |
menu_y = y; | |
button_h = 24; | |
button_w =190; | |
button_padding = 10; | |
menu_index = 0; | |
last_selected = 0; | |
// Button Array | |
button[0] = "New Game"; | |
button[1] = "Load Game"; | |
button[2] = "Options"; | |
button[3] = "Exit Game"; | |
buttons = array_length_1d(button); | |
// Array checker for unfold effect | |
var i = 0; | |
repeat(buttons) { | |
unfold[i] = 0; | |
i++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index variable | |
var i = 0; | |
repeat (buttons) { | |
// set up menu font | |
draw_set_font(ft_main); | |
draw_set_halign(fa_center); | |
draw_set_valign(fa_middle); | |
// horizontal and vertical location | |
xx = menu_x - 256 * (1 - unfold[i]); | |
yy = menu_y + (button_h + button_padding) * i; | |
// the box | |
draw_set_colour(c_dkgray); | |
draw_rectangle(xx, yy, xx + button_w, yy + button_h, false); | |
// font default color | |
draw_set_colour(c_ltgray); | |
// font selected color | |
if (menu_index == i) draw_set_colour(c_red); | |
// draw text and set to center of box. | |
draw_text(xx + button_w/2, yy + button_h/2, button[i]); | |
i++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// navigate the menu | |
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; | |
// unfold effect | |
var i = 0; | |
repeat(buttons) { | |
if (unfold[i] == 1) i++; | |
if (i < buttons) unfold[i] = min(1, unfold[i] + 0.02); | |
if (i + 1 < buttons) unfold[i + 1] = min(1, unfold[i + 1] + 0.005); | |
} | |
// tho sound effect | |
if (menu_index != last_selected) audio_play_sound(sd_menuswitch,1,false); | |
// check for selected | |
last_selected = menu_index; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment