Creating a movable arrow.

Hi guys I want to create a menu where you can move the arrow,

EX :

1
2
      > PLAY
         EXIT


I want to use GetAsyncKeyState(), but How can I do that ? any examples THX..
Last edited on
What do you have problem with?

"I do not know how to get user input but I heard that GetAsyncKeyState() might be good for it"
or
"I know how to use GetAsyncKeyState() and have used it, but I do not know how to use it in this case"
or something else?
"I know how to use GetAsyncKeyState() and have used it, but I do not know how to use it in this case"
Create array of menu items and have a variable which holds index of currently selected item.
Handle user input and change currently selected index accordingly then clear screen and redraw menu.
Example of redraw code:

1
2
3
4
5
6
7
8
9
10
11
//std::vector<std::string> menu ← holds all menu items
//int selected ← Holds currently selected index.

for(int i = 0; i < menu.size(); ++i) {
    if (i == selected)
        std::cout << "      > ";
    else
        std::cout << "         ";
    std::cout << menu[i] << '\n';
}
std::cout << std::flush;
Thanks :)
Topic archived. No new replies allowed.