Troubleshooting

I'm trying to test certain features in my game, but when i press "enter" on my main menu screen, it isn't getting on there. When I do it twice, I come to a black screen. I see that the memory line is red and very low. What do I do?
 

flyinian

Member
I'm trying to test certain features in my game, but when i press "enter" on my main menu screen, it isn't getting on there. When I do it twice, I come to a black screen. I see that the memory line is red and very low. What do I do?
Providing us your code would be a good start.

The code that you are using for the main menu "enter" and any other related code.
 

flyinian

Member
How do I report code?

Copy the code in question and paste it into the "code" field under the "..." (its hover over title is "insert")when making a reply.

1. Insert

2. </>Code

It should look something like this when you do a preview/send a reply.

GML:
if(something)
{blahblah};
 
Providing us your code would be a good start.

The code that you are using for the main menu "enter" and any other related code.
Step

var move = 0;
move -= max(keyboard_check_pressed(vk_up), keyboard_check_pressed(ord("W")), 0);
move += max(keyboard_check_pressed(vk_down), keyboard_check_pressed(ord("S")), 0);

if (move != 0)
{
mpos += move;
if (mpos < 0) mpos = array_length_1d(menu) - 1;
if (mpos > array_length_1d(menu) - 1) mpos = 0;
}

var push;
push = max(keyboard_check_released(vk_enter), keyboard_check_released(vk_shift), keyboard_check_released(vk_space), 0);
if (push ==1) scr_menu();

Draw

draw_set_halign(fa_left);
draw_set_valign(fa_middle);
draw_set_font(Harscapegame_font);
draw_set_color(c_white);

var m;
for (m = 0; m < array_length_1d(menu); m += 1)
{
draw_text(x + space, y + (m * space), string(menu[m]))
}

draw_sprite(sprite_index, 0, x + 16, y + mpos * space);

Create

menu[0] = "Start";
menu[1] = "Continue";
menu[2] = "Options";
menu[3] = "Quit";

space = 64;
mpos = 0;

And here is the script that goes with it...

switch (mpos)
{
case 0:
{
room_goto_next();
break;
}
case 1:
{
break;
}
case 2:
{
break;
}
case 3:
{
break;
}
default: break;
}
 

Roldy

Member
How do I report code?
When you write a post there is a toolbar. The button that looks like </> lets you post formatted code:
1596043070983.png

Choose gml as the code formatting type.

The compiler can read any garbage code you type as long as it is syntactically correct. However, you and other humans cannot. Try to make your code look as close as possible to english for easy readability.

For your specific problem I would suggest just using the debugger. Put a breakpoint in you scr_menu script and see if you break there and start stepping through your code to see how it is working.

Learn to use the debugger. It is an essential tool.
 

Yal

šŸ§ *penguin noises*
GMC Elder
If you run out of memory and nothing happens, there's probably an infinite loop either in the Enter key press event, or the Create event of something in the room you go to (e.g. in the Create event, the object creates another object of the same type, which in turn creates another one... etc)
 
Top