I'm currently writing a game in C++ in windows. Everything is going great so far, but my menu looks like this:
1.Go North
2.Go South
3.Go East
4.Go North
5.Inventory
6.Exit
Insert choice -
It works fine, but I have been using that sort of thing for a while and would rather one that you can navigate with the up and down arrows. How would I go about doing this?
Regards in advance
Have you considered using a console UI library such as ncurses?
In Windows, you can use the generic kbhit()
function. This function returns true/false depending on whether there is a keyboard hit or not. You can then use the getch()
function to read what is present on the buffer.
while(!kbhit()); // wait for input
c=getch(); // read input
You can also look at the scan codes. conio.h
contains the required signatures.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With