S
SARAndipitii
Guest
Hi!
So I'm a beginner when it comes to GMS and coding in general. I followed a tutorial for creating menus:
https://www.youtube.com/watch?v=fWAhi10q1ZE&
I followed everything to the letter with the exception of the general layout of the menus, some visual elements and controls, but I don't see my object at all. It's already added to the room and "visible" is checked.
Below is the code I'm using.
Create
Draw GUI
Step
I'm not getting any syntax errors, but I have no idea why it's not appearing.
What am I doing wrong?
So I'm a beginner when it comes to GMS and coding in general. I followed a tutorial for creating menus:
https://www.youtube.com/watch?v=fWAhi10q1ZE&
I followed everything to the letter with the exception of the general layout of the menus, some visual elements and controls, but I don't see my object at all. It's already added to the room and "visible" is checked.
Below is the code I'm using.
Create
Code:
gui_width = display_get_gui_width();
gui_height = display_get_gui_height();
gui_margin = 32;
menu_x = gui_width+200;
menu_y = gui_height - gui_margin;
menu_x_target = gui_width - gui_margin;
menu_speed = 25; //lower is faster
menu_font = font_main;
menu_itemheight = font_get_size(font_main);
menu_committed = -1;
menu_control = true;
menu[0] = "Continue";
menu[1] = "New Game";
menu[2] = "Settings";
menu[3] = "Credits";
menu[4] = "Exit";
menu_items = array_length_1d(menu);
menu_cursor = 2;
Draw GUI
Code:
draw_set_font(font_main);
draw_set_halign(fa_left);
draw_set_valign(fa_middle);
for (var i = 0; i < menu_items; i++)
{
var offset = 2;
var txt = menu[i];
if (menu_cursor == i)
{
txt = string_insert("> ", txt, 0);
var col = c_white;
}
else
{
var col = c_gray;
}
var xx = menu_x;
var yy = menu_y - (menu_itemheight * (i * 1.5));
draw_set_color(c_white);
draw_text(xx-offset,yy,txt);
draw_text(xx+offset,yy,txt);
draw_text(xx,yy+offset,txt);
draw_text(xx,yy-offset,txt);
draw_set_color(col);
draw_text(xx,yy,txt);
}
Step
Code:
if (menu_control)
{
if (keyboard_check_pressed(vk_up)) or keyboard_check_pressed(ord("W"))
{
menu_cursor++;
if (menu_cursor >= menu_items) menu_cursor = 0;
}
if (keyboard_check_pressed(vk_down)) or keyboard_check_pressed(ord("S"))
{
menu_cursor--;
if (menu_cursor < 0) menu_cursor = menu_items-1;
}
if (keyboard_check_pressed(vk_enter)) or keyboard_check_pressed(vk_space)
{
menu_x_target = gui_width+200;
menu_committed = menu_cursor;
menu_control = false;
}
}
if (menu_x > gui_width+150) && (menu_committed != -1)
{
switch (menu_committed)
{
case 0: game_end(); break;
}
}
I'm not getting any syntax errors, but I have no idea why it's not appearing.
What am I doing wrong?