I have a nice menu system and I would like to move an arrow around defending on selection. I'm testing this out so I only have a situation build for the down key, but eventually I would have down and up arrows.
I got it to work because I figured out after I press the down key, choice is 224. I ran into a new problem where the UP arrow key is also 224...
char selector[4] = {'>',' ',' ',' '};
while (1)
{
DisplayMenu();
printf(" Main Menu: \n");
printf(" %c Log in \n", selector[0]);
printf(" %c Display High Scores \n", selector[1]);
printf(" %c Start Game \n", selector[2]);
printf(" %c Exit \n", selector[3]);
choice = getch();
switch (choice)
{
case 224:
for (int i = 0; i < 4; i++)
{
if (selector[i] == '>')
{
selector[i] = ' ';
i++;
selector[i] = '>';
}
}
break;
}
system("cls");
}
return numberChoice;
My theory was when the down key is pressed, move the '>' over in the char array and then when the menu is displayed, it would show either the '>' or a space, giving it the illusion that your moving around in the menu options. Of course, I can't seem to find a way to detect what the down arrow was. Any help?