E
epYa
Guest
Hey,
I'm fairly new to GML and I tried to do a starting menu.
So the menu works from the navigation, you can go up and down with the arrow keys.
The variable location tells me, which button I'm currently at and it also paints the text red, that works great!
However if I want to check if location is 3 and the enter button is pressed, it works even if location isn't 3.
I tried to draw location and somehow all the numbers seem to overlap. What's wrong with my code?
This is how the Step-Event of my code looks like:
Draw Gui event:
Thanks in advance!
I'm fairly new to GML and I tried to do a starting menu.
So the menu works from the navigation, you can go up and down with the arrow keys.
The variable location tells me, which button I'm currently at and it also paints the text red, that works great!
However if I want to check if location is 3 and the enter button is pressed, it works even if location isn't 3.
I tried to draw location and somehow all the numbers seem to overlap. What's wrong with my code?
This is how the Step-Event of my code looks like:
Code:
if(keyboard_check_pressed(vk_down) && (location != 3)) {
location += 1;
}else if(keyboard_check_pressed(vk_down) && (location == 3)){
location = 1;
}
else if(keyboard_check_pressed(vk_up) && (location != 1)) {
location -= 1;
} else if(keyboard_check_pressed(vk_up) && (location==1)) {
location = 3;
}
if(location == 1){
colorbuttonc = c_maroon;
colorbuttonn = c_white;
colorbuttonq = c_white;}
else if(location == 2){
colorbuttonc = c_white;
colorbuttonn = c_maroon;
colorbuttonq = c_white;}
else if(location == 3){
colorbuttonc = c_white;
colorbuttonn = c_white;
colorbuttonq = c_maroon;}
if(keyboard_check_pressed(vk_enter)) {
switch( location ){
case 1: // Resume
break;
case 2: // newgame
break;
case 3: // Exit
game_end();
break;
}
}
Code:
draw_text_colour(350,450,"<Continue>",colorbuttonc,colorbuttonc,colorbuttonc,colorbuttonc,image_alpha);
draw_text_colour(350,500,"<New Game>",colorbuttonn,colorbuttonn,colorbuttonn,colorbuttonn,image_alpha);
draw_text_colour(350,550,"<Quit>",colorbuttonq,colorbuttonq,colorbuttonq,colorbuttonq,image_alpha);
draw_text_colour(350,600,location,colorbuttonq,colorbuttonq,colorbuttonq,colorbuttonq,image_alpha);