Creating a menu interface

This is a discussion on Creating a menu interface within the C++ Programming forums, part of the General Programming Boards category; I'm trying to create a menu for my animal guessing game. This is the simple menu I am currently using: ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    17

    Creating a menu interface

    I'm trying to create a menu for my animal guessing game. This is the simple menu I am currently using:

    Code:
    do
           {
              system ("CLS");  
              cout << " |                              Twenty Questions                             |\n"
                   << " ?---?---?---?---?---?---?---?---?---?---?---?---?---?---?---?---?---?---?---?\n"
                   << " |                                                                           |\n"
                   << " |   1. Read the directions                                                  |\n"
                   << " |   2. Play the game                                                        |\n"
                   << " |   3. Find out how many animals I know                                     |\n"
                   << " |   4. Reset my database                                                    |\n"
                   << " |   5. Exit program                                                         |\n"
                   << " |                                                                           |\n\n"
                   << "Choose an option: \n";
              cin >> option;
              switch (option)
              {
                 case '1': directions(); break;
                 case '2': playTheGame(animals); break;
                 case '3': countAnimals(animals); break;
                 case '4': reset(animals); break;  
                 case '5': if(exit(animals)) return; break;
              }
           }
           while (true);
    This is what I want it to look like:

    Code:
    |                              Twenty Questions                             |
    ?---?---?---?---?---?---?---?---?---?---?---?---?---?---?---?---?---?---?---?
    |                                                                           |
    |   >  Read the directions                                                  |
    |      Play the game                                                        |
    |      Find out how many animals I know                                     |
    |      Reset my database                                                    |
    |      Exit program                                                         |
    |                                                                           |
      Use the arrow keys to select an option.
    As you can see, I want my program to move the '>' character up and down to select an option. Don't worry about telling me how to input directional keys, I've figured that out. All I want to know is, if there is a way, how to move that cursor up and down without using a loop that clears the screen and outputs again and again.

    Or in simpler terms, how do I move the blinking | thing wherever I want.

  2. #2
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    There is not standard way to do this, if you are just targeting windows, I think there is some header you can use (conio.h? *shrug*) or you can pick up PDCurses which is some funstuff.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    17
    I was pretty sure I would have to #include <conio.h>. I'm just asking for some code that will allow me to move the output line to whatever space necessary. I remember being able to do it in Pascal; however, like text colors, this appears to be a lot more complicated in C++.

    Also, could you give me some more information on PDCurses? I could try that..

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,318
    Search for adrianxw's console tutorial, it would probably help with this.

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    17
    Ah, this tutorial looks like a winner. I'll post again when I find something.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    17
    Gold mine: http://www.adrianxw.dk/SoftwareSite/index.html
    Many thanks to Daved for the tip, and adiranxw for the great tutorial.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 09:25 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  4. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21