hello, since i m trying to create a game written in c, i got into another strange problem with ctrulib.
here it is:
I created a start menu for my game. I got into some problems with i could solve (like flickering selector in front of the option, and a really "sensitive"key press, meaning that if i press the key one time, it can skip up to 3 options).
Now the menu was working correctly i wanted to clean up my code and copied every function for it in another .c file. But right after I did the the menu got really sensitive again (without changing the core code).
I Think i know why it happens, as it scanning for the keysdown is included in the while loop, which happens really fast. so it can scan it pressed 3 times while i am actually pressing it one time (but then, what is the difference between hidKeysDown and hidKeysHeld?)
but right now I am riddled with this, so does anybody have an idea on how to "fix"this?
here is my part of the code
here it is:
I created a start menu for my game. I got into some problems with i could solve (like flickering selector in front of the option, and a really "sensitive"key press, meaning that if i press the key one time, it can skip up to 3 options).
Now the menu was working correctly i wanted to clean up my code and copied every function for it in another .c file. But right after I did the the menu got really sensitive again (without changing the core code).
I Think i know why it happens, as it scanning for the keysdown is included in the while loop, which happens really fast. so it can scan it pressed 3 times while i am actually pressing it one time (but then, what is the difference between hidKeysDown and hidKeysHeld?)
but right now I am riddled with this, so does anybody have an idea on how to "fix"this?
here is my part of the code
menu[0] = 0;
menu[1] = 1;
hidScanInput();
kDown = hidKeysDown();
enum Menu{
single = 0, multi = 1, highscores = 2, exit = 3
};
drawpicture(0);
drawline(5, 5, 315, 5, 47, 88, 17);
drawline(5, 5, 5, 235, 47, 88, 17);
drawline(5, 235, 315, 235, 47, 88, 17);
drawline(315, 5, 315, 235, 47, 88, 17);
printf("\x1b[10;3HSingle Player");
printf("\x1b[12;3HMulti Player");
printf("\x1b[14;3HHighscores");
printf("\x1b[16;3HExit");
printf("\x1b[28;24HVersion: %s", version);
while (true)
{
hidScanInput();
kDown = hidKeysDown();
if (kDown&KEY_DDOWN)
startselector(+1);
if (kDown&KEY_DUP)
startselector(-1);
if (kDown&KEY_A)
{
if (menu[0] == single)
start_single();
if (menu[0] == multi)
start_multi();
if (menu[0] == highscores)
start_highscores();
if (menu[0] == exit)
break;
}
//printf("\x1b[18;3H%d %d", menu[0], menu[1]);
if (menu[1] != menu[0])
{
clearrow1();// this clears the row with the "selector(X)"
if (menu[0] == single)
printf("\x1b[10;1HX ");
if (menu[0] == multi)
printf("\x1b[12;1HX ");
if (menu[0] == highscores)
printf("\x1b[14;1HX ");
if (menu[0] == exit)
printf("\x1b[16;1HX ");
}
if (kDown & KEY_START) break;
menu[1] = menu[0];
}