makin progress

This is a discussion on makin progress within the C++ Programming forums, part of the General Programming Boards category; ok so many times i have been helped by you guys (and girls) and so many times have i thought ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    176

    makin progress

    ok so many times i have been helped by you guys (and girls) and so many times have i thought "should be smooth sailing from here" and i always run into another problem well here is my code

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main(void)
    {
        string whattheytype;
        string whattheytype2;
        string whattheytype3;
        string commands = "commands";
        string option1 = "start";
        string theory = "theory";/*variables*/
        string game ="game";
        string leave = "exit";
        int pause;
        int more;
        
        
        std::cout<<"this game was ripped off from the choose your own adventure\n";
        std::cout<<" book called Undergound Kingdom by  Edward Packard\n";
        std::cout<<"ok this is a choose your own adventure game called\n";
        std::cout<<"Underground kingdom. you will read the page then you will be\n";
        std::cout<<"asked to choose which way you want to go and such\n";
        std::cout<<"sounds like fun huh? thought so. ok type commands to\n";
        std::cout<<"get a list of commands. and type exit to leave";/* all this is is the introductory for the game*/
        std::cout<<"\ntype start to start the game!\n"<<endl;
        
        std::cin>>whattheytype;/* beginning commands*/
        if (whattheytype == commands) 
        {
        std::cout<<"just follow the instructions and restart the program\n"<<endl;/*insructions*/
        }
        else 
        if (whattheytype == "exit")
        {
        std::cout<<"goodbye\n";
        }
       else
       if (whattheytype != "start")
       {
       std::cout<<"that is not a command restart the game\n";
       } 
         else
        if (whattheytype == "start")/*beginning of actual game*/
        {
        std::cout<<"WARNING!!!!!!!!!!!!!\n";
        std::cout<<"\n"<<endl;
        std::cout<<"The Underground Kingdom is not easy to reach. Many Players\n";
        std::cout<<"never get ther. Others never return.\n";
        std::cout<<"    Before starting out on your journey, you may want to read\n";
        std::cout<<"Professor Bruckner's theory, which is set fourth on the next block\n";
        std::cout<<"of text.\n";
        std::cout<<"    Professor Bruckner is a rather boring writer, and i wouldn't\n";
        std::cout<<"suggest that you bother read his theory exept that, if you ever\n";
        std::cout<<"get to the Underground Kingdom, it might save your life. Good luck!\n"<<endl;
        std::cout<<"type theory to read the theory type game to start the game\n";
            
            }
            std::cin>>whattheytype2;
            if (whattheytype2 == "game")
            {
            std::cout<<"game would go here\n";
            system("pause");
            }
            else
            if (whattheytype2 == "theory")
                {
                std::cout<<"                         PROFESSOR\n";
                std::cout<<"                         BRUCKNER'S\n";
                std::cout<<"                           THEORY\n";
                std::cout<<"---------------------------------------------------------------\n";
                std::cout<<"The discovery of the Bottomless Crevasse in Greenland by Dr. Nera \n";
                std::cout<<"Vivaldi supports my therory that the earth is not solid, as has\n";
                std::cout<<"been thought, but that it is hollow.  The Bottomless Crevasse is\n";
                std::cout<<"probably the sole route from the earth's surface to a vast Underground\n";
                std::cout<<"Kingdom.  The only other possible link would be an underground river,\n";
                std::cout<<"flowing in alternating directions in response to the tides, but this \n";
                std::cout<<"seems unlikely.\n";
                std::cout<<"How you may ask, was the earth hollowed out?  My studies show that more\n";
                std::cout<<"than a billion years ago a tiny blck hole collided with out planet and\n";
                std::cout<<"lodged in its center, pulling the whole molten core into an incredibly\n";
                std::cout<<"massive sphere only a few hundred meter across.\n";
                std::cout<<"If you were to stand on the inner surface of the earth, like a fly on the\n";
                std::cout<<"shell of an enormous pumpkin, you would see the black hole directly overhead,\n";
                std::cout<<"press any key and hit enter for more of the theory\n";
                std::cin>>more;
                std::cout<<"like a black sun.\n";
                std::cout<<"The Gravity of the earth's thick shell would hold you to the inner shell\n";
                std::cout<<"of the earth, though you would weigh much less than you would on the\n";
                std::cout<<"outer surface because the mass of the Black Sun would tend to pull \n";
                std::cout<<"you toward it. If there were a very tall mountain in the Underground\n";
                std::cout<<"Kingdom and you were to climb to the top of it, you might be pulled\n";
                std::cout<<"up into the Black Sun because gravity gets stronger as you approach\n";
                std::cout<<"a massive object.\n";
                std::cout<<"In all other respects the Black Sun would not be dangerous to any creatures\n";
                std::cout<<"in the Unerground Kingdom.  On the contrary, the Black Sun would be\n";
                std::cout<<"necessary to life in th underworld, but in the opposit way that the sun is\n";
                std::cout<<"necessary to life on the earth's surface.  OUr sun give us heat and keeps us\n";
                std::cout<<"from freezing.  The Black Sun absorbs heat.  If there is an underground \n";
                std::cout<<"kingdom, it is the Blac Sun tha keep its inhabitants from being baked to\n";
                std::cout<<"death by the heat within the earth.\n";
                std::cout<<"type game to start the game\n";
                std::cin>>whattheytype3;
    }
    if (whattheytype3 == "game")
    {
    std::cout<<"game would go here";
    }
    else
    if (whattheytype3 != "game")
    {
    std::cout<<"i dont understand";
    }
    return 0;
    
    }
    what i want to happen is when you get dont reading the theory you can type game and it will start the game text the only way i could think was to make another variable and make that one the same as whatyoutype2 i would like it to just be able to execute whatyoutype2 == "game" but i dont know how if thats not possible (and i think it is) all that happens when you get done reading the theory is the program closes i tried using system("pause"); but that just paused the program then closed it also the cout is taking up a lotta space so if anyone knows one command that will let me put out a lot of text that would be cool also. anyother sudgestions would be nice but thats my problem i been workin on it for about a week i am a n00b badly but whatever everyone starts somewhere.

  2. #2
    Registered User
    Join Date
    Jan 2004
    Posts
    4
    first of all, why doe you use 3 vars?

    as they aren't const, just reuse them :s

    second: Maybe because I don't speak english very well, maybe you didn't explain well, however, i haven't got a clue what you think is wrong :s

    (wild guess: read the part functions in your manual)

    for the rest: U can use a while loop for instance
    Code:
    cin>>type;
    while(type != "exit)
    {
    
    //end
    cin>>type;
    }
    But i don't know what you've seen already in C++

    btw: instead of using always std::cout or std::cin

    just put using namespace std; after your header declaration

  3. #3
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    >Just put using namespace std; after your header declaration.

    Actaully, std :: cout etc. is better then namespace std. It's is actaully the worst form of this. At least use:

    Code:
    using std :: cin;
    using std :: cout;
    using std :: endl;
    //...
    By the way, this same thing was posted in the game section awhile back. I remember it. Was that you? If so, was your problem not solved back then?

    - SirCrono6
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    176
    i remember posting they told me to come here i have posted this code here and got a lot of help what i really need is to make the program not exit on the theory part and not have to type the game thing twice i am assuming thats what the loop is for? and i and a super n00b but learn fast so yah....

  5. #5
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    killgore has a good suggest about the while loop (I don't agree with his using namespace std; suggestion, though). However, I think your specific problem is that you should replace this:

    std::cin>>more;

    with this:

    system("pause");

    Your old way didn't work because the user had to type a letter and then Enter. Your "std::cin>>more;" read the letter from the input stream, but not the newline from the Enter key. Later, your "std::cin>>whattheytype3;" read the newline from the input stream instead of the next command. Changing it to the pause will be similar to the rest of your program and won't leave anything in the input stream.

    Also try fixing your indentation and adding a blank line between each section of code to make it more readable. Of course, the rest of your code and logic could be a little better, but I'm sure you'll figure it out as you go along.

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    176
    k thanks a lot

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    176
    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main(void)
    {
        string whattheytype;
        string whattheytype2;
        string commands = "commands";
        string option1 = "start";
        string theory = "theory";/*variables*/
        string game ="game";
        string leave = "exit";
        int pause;
        int more;
        
        
        std::cout<<"this game was ripped off from the choose your own adventure\n";
        std::cout<<" book called Undergound Kingdom by  Edward Packard\n";
        std::cout<<"ok this is a choose your own adventure game called\n";
        std::cout<<"Underground kingdom. you will read the page then you will be\n";
        std::cout<<"asked to choose which way you want to go and such\n";
        std::cout<<"sounds like fun huh? thought so. ok type commands to\n";
        std::cout<<"get a list of commands. and type exit to leave";/* all this is is the introductory for the game*/
        std::cout<<"\ntype start to start the game!\n"<<endl;
        
        std::cin>>whattheytype;/* beginning commands*/
        if (whattheytype == commands) 
        {
        std::cout<<"just follow the instructions and restart the program\n"<<endl;/*insructions*/
        }
        else 
        if (whattheytype == "exit")
        {
        std::cout<<"goodbye\n";
        }
       else
       if (whattheytype != "start")
       {
       std::cout<<"that is not a command restart the game\n";
       } 
         else
        if (whattheytype == "start")/*beginning of actual game*/
        {
        std::cout<<"WARNING!!!!!!!!!!!!!\n";
        std::cout<<"\n"<<endl;
        std::cout<<"The Underground Kingdom is not easy to reach. Many Players\n";
        std::cout<<"never get ther. Others never return.\n";
        std::cout<<"    Before starting out on your journey, you may want to read\n";
        std::cout<<"Professor Bruckner's theory, which is set fourth on the next block\n";
        std::cout<<"of text.\n";
        std::cout<<"    Professor Bruckner is a rather boring writer, and i wouldn't\n";
        std::cout<<"suggest that you bother read his theory exept that, if you ever\n";
        std::cout<<"get to the Underground Kingdom, it might save your life. Good luck!\n"<<endl;
        std::cout<<"type theory to read the theory type game to start the game\n";
            
            }
            std::cin>>whattheytype2;
            if (whattheytype2 == "game")
            {
            std::cout<<"game would go here\n";
            system("pause");
            }
            else
            if (whattheytype2 == "theory")
                {
                std::cout<<"                         PROFESSOR\n";
                std::cout<<"                         BRUCKNER'S\n";
                std::cout<<"                           THEORY\n";
                std::cout<<"---------------------------------------------------------------\n";
                std::cout<<"The discovery of the Bottomless Crevasse in Greenland by Dr. Nera \n";
                std::cout<<"Vivaldi supports my therory that the earth is not solid, as has\n";
                std::cout<<"been thought, but that it is hollow.  The Bottomless Crevasse is\n";
                std::cout<<"probably the sole route from the earth's surface to a vast Underground\n";
                std::cout<<"Kingdom.  The only other possible link would be an underground river,\n";
                std::cout<<"flowing in alternating directions in response to the tides, but this \n";
                std::cout<<"seems unlikely.\n";
                std::cout<<"How you may ask, was the earth hollowed out?  My studies show that more\n";
                std::cout<<"than a billion years ago a tiny blck hole collided with out planet and\n";
                std::cout<<"lodged in its center, pulling the whole molten core into an incredibly\n";
                std::cout<<"massive sphere only a few hundred meter across.\n";
                std::cout<<"If you were to stand on the inner surface of the earth, like a fly on the\n";
                std::cout<<"shell of an enormous pumpkin, you would see the black hole directly overhead,\n";
                std::cout<<"press any key and hit enter for more of the theory\n";
                std::cin>>more;
                std::cout<<"like a black sun.\n";
                std::cout<<"The Gravity of the earth's thick shell would hold you to the inner shell\n";
                std::cout<<"of the earth, though you would weigh much less than you would on the\n";
                std::cout<<"outer surface because the mass of the Black Sun would tend to pull \n";
                std::cout<<"you toward it. If there were a very tall mountain in the Underground\n";
                std::cout<<"Kingdom and you were to climb to the top of it, you might be pulled\n";
                std::cout<<"up into the Black Sun because gravity gets stronger as you approach\n";
                std::cout<<"a massive object.\n";
                std::cout<<"In all other respects the Black Sun would not be dangerous to any creatures\n";
                std::cout<<"in the Unerground Kingdom.  On the contrary, the Black Sun would be\n";
                std::cout<<"necessary to life in th underworld, but in the opposit way that the sun is\n";
                std::cout<<"necessary to life on the earth's surface.  OUr sun give us heat and keeps us\n";
                std::cout<<"from freezing.  The Black Sun absorbs heat.  If there is an underground \n";
                std::cout<<"kingdom, it is the Blac Sun tha keep its inhabitants from being baked to\n";
                std::cout<<"death by the heat within the earth.\n";
                std::cout<<"type game to start the game\n";
             }
             cin>>whattheytype2;
             while(whattheytype2 != "exit")
            {
    
             //end
             cin>>whattheytype2;
             }
    
    
    if (whattheytype2 != "game")
    {
    std::cout<<"i dont understand";
    }
    return 0;
    }
    now it wont let anything be typed after you read the theory
    Last edited by sreetvert83; 01-16-2004 at 02:41 PM.

  8. #8
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,156
    i think what you really want is an array of strings that are the commands you accept to the game and after typing in a command look thru the list of valid commands and call a function to do the operation the command specifies if you dont recognize the command type out 'illegal command' you can also have a command to list all the valid commands make more functions and in main() really just consists of a loop to process each command 'exit' will actually exit the loop and end the game you might want to use punctuation in your posts from this point on so we can actually read them easier as you can see this post although it has good advice is as difficult to read as your posts have been
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  9. #9
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    I agree with WaltP, but you never replaced:

    std::cin>>more;

    with this:

    system("pause");

    Did you understand the reason why I suggested that?

  10. #10
    Registered User
    Join Date
    Mar 2003
    Posts
    176
    as soon as i had posted that i changed it to system("pause"), so ya i did and Waltp can you explain what you mean? I kind of understand i think.... your saying use less variable right? As in use whattheytype for pretty much everything? I think i tried that and it wouldn't do what i wanted. It like just wouldn't let you type in what you wanted or something i'm probably wrong but please explaine, thanks.

  11. #11
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    now it wont let anything be typed after you read the theory
    Everything they say does not fix that problem. I commented out all that "theory" output and it fixed it. But then ... I don't know. The console window can't handle that many couts'??? HUH??
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  12. #12
    Registered User
    Join Date
    Mar 2003
    Posts
    176
    Not sure what you mean but this is the code as i have it now

    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main(void)
    {
        string whattheytype;
        string whattheytype2;
        string commands = "commands";
        string option1 = "start";
        string theory = "theory";/*variables*/
        string game ="game";
        string leave = "exit";
        int pause;
        int more;
        
        
        std::cout<<"this game was ripped off from the choose your own adventure\n";
        std::cout<<" book called Undergound Kingdom by  Edward Packard\n";
        std::cout<<"ok this is a choose your own adventure game called\n";
        std::cout<<"Underground kingdom. you will read the page then you will be\n";
        std::cout<<"asked to choose which way you want to go and such\n";
        std::cout<<"sounds like fun huh? thought so. ok type commands to\n";
        std::cout<<"get a list of commands. and type exit to leave";/* all this is is the introductory for the game*/
        std::cout<<"\ntype start to start the game!\n"<<endl;
        
        std::cin>>whattheytype;/* beginning commands*/
        if (whattheytype == commands) 
        {
        std::cout<<"just follow the instructions and restart the program\n"<<endl;/*insructions*/
        }
        else 
        if (whattheytype == "exit")
        {
        std::cout<<"goodbye\n";
        }
       else
       if (whattheytype != "start")
       {
       std::cout<<"that is not a command restart the game\n";
       } 
         else
        if (whattheytype == "start")/*beginning of actual game*/
        {
        std::cout<<"WARNING!!!!!!!!!!!!!\n";
        std::cout<<"\n"<<endl;
        std::cout<<"The Underground Kingdom is not easy to reach. Many Players\n";
        std::cout<<"never get ther. Others never return.\n";
        std::cout<<"    Before starting out on your journey, you may want to read\n";
        std::cout<<"Professor Bruckner's theory, which is set fourth on the next block\n";
        std::cout<<"of text.\n";
        std::cout<<"    Professor Bruckner is a rather boring writer, and i wouldn't\n";
        std::cout<<"suggest that you bother read his theory exept that, if you ever\n";
        std::cout<<"get to the Underground Kingdom, it might save your life. Good luck!\n"<<endl;
        std::cout<<"type theory to read the theory type game to start the game\n";
            
            }
            std::cin>>whattheytype2;
            if (whattheytype2 == "game")
            {
            std::cout<<"game would go here\n";
            system("pause");
            }
            else
            if (whattheytype2 == "theory")
                {
                std::cout<<"                         PROFESSOR\n";
                std::cout<<"                         BRUCKNER'S\n";
                std::cout<<"                           THEORY\n";
                std::cout<<"---------------------------------------------------------------\n";
                std::cout<<"The discovery of the Bottomless Crevasse in Greenland by Dr. Nera \n";
                std::cout<<"Vivaldi supports my therory that the earth is not solid, as has\n";
                std::cout<<"been thought, but that it is hollow.  The Bottomless Crevasse is\n";
                std::cout<<"probably the sole route from the earth's surface to a vast Underground\n";
                std::cout<<"Kingdom.  The only other possible link would be an underground river,\n";
                std::cout<<"flowing in alternating directions in response to the tides, but this \n";
                std::cout<<"seems unlikely.\n";
                std::cout<<"How you may ask, was the earth hollowed out?  My studies show that more\n";
                std::cout<<"than a billion years ago a tiny blck hole collided with out planet and\n";
                std::cout<<"lodged in its center, pulling the whole molten core into an incredibly\n";
                std::cout<<"massive sphere only a few hundred meter across.\n";
                std::cout<<"If you were to stand on the inner surface of the earth, like a fly on the\n";
                std::cout<<"shell of an enormous pumpkin, you would see the black hole directly overhead,\n";
                std::cout<<"press any key and hit enter for more of the theory\n";
                system("pause");
                std::cout<<"like a black sun.\n";
                std::cout<<"The Gravity of the earth's thick shell would hold you to the inner shell\n";
                std::cout<<"of the earth, though you would weigh much less than you would on the\n";
                std::cout<<"outer surface because the mass of the Black Sun would tend to pull \n";
                std::cout<<"you toward it. If there were a very tall mountain in the Underground\n";
                std::cout<<"Kingdom and you were to climb to the top of it, you might be pulled\n";
                std::cout<<"up into the Black Sun because gravity gets stronger as you approach\n";
                std::cout<<"a massive object.\n";
                std::cout<<"In all other respects the Black Sun would not be dangerous to any creatures\n";
                std::cout<<"in the Unerground Kingdom.  On the contrary, the Black Sun would be\n";
                std::cout<<"necessary to life in the underworld, but in the opposit way that the sun is\n";
                std::cout<<"necessary to life on the earth's surface.  Our sun give us heat and keeps us\n";
                std::cout<<"from freezing.  The Black Sun absorbs heat.  If there is an underground \n";
                std::cout<<"kingdom, it is the Black Sun tha keep its inhabitants from being baked to\n";
                std::cout<<"death by the heat within the earth.\n";
                std::cout<<"type game to start the game\n";
             
              std::cin>>whattheytype2;
              while(whattheytype2 != "game")
              std::cout<<"I dont understand";                       
              std::cin>>whattheytype2;
              }
    
    return 0;
    }
    I am going to keep messing with it and see if i can get any results from it, ill keep checking back here and if i figure it out ill pos thte solution in case anyone else has this problem.

  13. #13
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    This is the last part should be. And it should work fine.
    Code:
              std::cin>>whattheytype2;
              
              while(whattheytype2 != "game") {
                  std::cout<<"I dont understand\n";                       
                  std::cin>>whattheytype2;
              }
                  
              std::cout << "Game goes here\n";
              system("pause");
          }
    
          return 0;
    }
    Also, I found the bug from your previous problem.
    Code:
    ....
    int more;
    ....
    std::cout<<"press any key and hit enter for more of the theory\n";
    std::cin>>more;
    
    ....
    more is declared an int , so when you get that "press any key" message and you enter something other than an int, subsequent cin won't take any input (you can't type anything on the screen) until the fail stream is cleared. But when you enter an int, the rest of the program will run as you have expected.
    Last edited by alphaoide; 01-16-2004 at 10:57 PM.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  14. #14
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,156
    Originally posted by sreetvert83
    as soon as i had posted that i changed it to system("pause"), so ya i did and Waltp can you explain what you mean? I kind of understand i think.... your saying use less variable right? As in use whattheytype for pretty much everything? I think i tried that and it wouldn't do what i wanted. It like just wouldn't let you type in what you wanted or something i'm probably wrong but please explaine, thanks.
    Thank you for punctuation. You sound much clearer now.

    Start by defining all the commands you want to create, and defines to alias them:
    Code:
    string Commands[] = {"save","exit","game",""}; // and so on
    #define SAVE 0  // these match the index of Commands[]
    #define EXIT 1
    #define GAME 2
    Now in your main, set up a loop:
    Code:
    do
    {
        ReadInputFromUser
        j = 0; // counter to get the command
        while (Commands[j] != "" && Commands[j] != inputline)  
            j++;
        switch(j)
        {
          case SAVE:
              CallSaveFunction();
              break;
          case GAME:
              CallGameFunction();
              break;
          case EXIT:
              CallExitFunction();
              break;
          default:
              cout << "Illegal function" << endl;
              break;
        }
    } while (inputline != Commands[EXIT]);
    If you don't know the switch statement, change to
    Code:
    if ()
    {
    }
    else if()
    {
    }
    else
    {
    }
    This is not the most elegant solution, but once you understand this, it can be cleaned up to be much more concise.

    Also, for posting to get help, it might be better to remove a lot of the cout calls because they just get in the way. Once you get the logic fixed, add them back.

    And since you are using C++, instead of system("pause"); just go a cin to stop the program from exiting. No sense calling the OS when C++ can do what you want.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  15. #15
    Registered User
    Join Date
    Mar 2003
    Posts
    176
    when i tried to take some of the couts out i ended up skrewing it up and making it not work right so ill just post the whole code
    [CODE#include <iostream>
    #include <string>
    using namespace std;

    int main(void)
    {
    string whattheytype;
    string whattheytype2;
    string Commands[] = {"theory","exit","game","commands"}; // and so on
    // these match the index of Commands[]
    #define EXIT 1
    #define GAME 2
    #define THEORY 3
    /*variables*/
    {
    std::cout<<"this game was ripped off from the choose your own adventure\n";
    std::cout<<" book called Undergound Kingdom by Edward Packard\n";
    std::cout<<"ok this is a choose your own adventure game called\n";
    std::cout<<"Underground kingdom. you will read the page then you will be\n";
    std::cout<<"asked to choose which way you want to go and such\n";
    std::cout<<"sounds like fun huh? thought so. ok type commands to\n";
    std::cout<<"get a list of commands. and type exit to leave";/* all this is is the introductory for the game*/
    std::cout<<"\ntype start to start the game!\n"<<endl;
    std::cin>>whattheytype;/* beginning commands*/
    }
    if (whattheytype == "commands")
    {
    std::cout<<"the commands are exit and start\n"<<endl;/*insructions*/
    std::cin>>whattheytype;
    }
    else
    if (whattheytype == "exit")
    {
    std::cout<<"goodbye\n";
    }
    else
    if (whattheytype == "start")/*beginning of actual game*/
    {
    std::cout<<"WARNING!!!!!!!!!!!!!\n";
    std::cout<<"\n";
    std::cout<<"The Underground Kingdom is not easy to reach. Many Players\n";
    std::cout<<"never get ther. Others never return.\n";
    std::cout<<" Before starting out on your journey, you may want to read\n";
    std::cout<<"Professor Bruckner's theory, which is set fourth on the next block\n";
    std::cout<<"of text.\n";
    std::cout<<" Professor Bruckner is a rather boring writer, and i wouldn't\n";
    std::cout<<"suggest that you bother read his theory exept that, if you ever\n";
    std::cout<<"get to the Underground Kingdom, it might save your life. Good luck!\n"<<endl;
    std::cout<<"type theory to read the theory type game to start the game\n";
    std::cin>>whattheytype2;
    }
    while(whattheytype2 != "game","theory") {
    std::cout<<"I dont understand type game or theory\n";
    std::cin>>whattheytype2;
    {
    std::cout << "Game goes here\n";
    system("pause");
    }

    if (whattheytype2 == "theory")
    {
    std::cout<<" PROFESSOR\n";
    std::cout<<" BRUCKNER'S\n";
    std::cout<<" THEORY\n";
    std::cout<<"---------------------------------------------------------------\n";
    std::cout<<"The discovery of the Bottomless Crevasse in Greenland by Dr. Nera \n";
    std::cout<<"Vivaldi supports my therory that the earth is not solid, as has\n";
    std::cout<<"been thought, but that it is hollow. The Bottomless Crevasse is\n";
    std::cout<<"probably the sole route from the earth's surface to a vast Underground\n";
    std::cout<<"Kingdom. The only other possible link would be an underground river,\n";
    std::cout<<"flowing in alternating directions in response to the tides, but this \n";
    std::cout<<"seems unlikely.\n";
    std::cout<<"How you may ask, was the earth hollowed out? My studies show that more\n";
    std::cout<<"than a billion years ago a tiny blck hole collided with out planet and\n";
    std::cout<<"lodged in its center, pulling the whole molten core into an incredibly\n";
    std::cout<<"massive sphere only a few hundred meter across.\n";
    std::cout<<"If you were to stand on the inner surface of the earth, like a fly on the\n";
    std::cout<<"shell of an enormous pumpkin, you would see the black hole directly overhead,\n";
    std::cout<<"press any key and hit enter for more of the theory\n";
    system("pause");
    std::cout<<"like a black sun.\n";
    std::cout<<"The Gravity of the earth's thick shell would hold you to the inner shell\n";
    std::cout<<"of the earth, though you would weigh much less than you would on the\n";
    std::cout<<"outer surface because the mass of the Black Sun would tend to pull \n";
    std::cout<<"you toward it. If there were a very tall mountain in the Underground\n";
    std::cout<<"Kingdom and you were to climb to the top of it, you might be pulled\n";
    std::cout<<"up into the Black Sun because gravity gets stronger as you approach\n";
    std::cout<<"a massive object.\n";
    std::cout<<"In all other respects the Black Sun would not be dangerous to any creatures\n";
    std::cout<<"in the Unerground Kingdom. On the contrary, the Black Sun would be\n";
    std::cout<<"necessary to life in the underworld, but in the opposit way that the sun is\n";
    std::cout<<"necessary to life on the earth's surface. Our sun give us heat and keeps us\n";
    std::cout<<"from freezing. The Black Sun absorbs heat. If there is an underground \n";
    std::cout<<"kingdom, it is the Black Sun that keep its inhabitants from being baked to\n";
    std::cout<<"death by the heat within the earth.\n";
    std::cout<<"type game to start the game\n";
    std::cin>>whattheytype2;
    }
    while(whattheytype2 != "game","theory")
    {
    std::cout<<"I dont understand\n";
    std::cin>>whattheytype2;
    }
    std::cout << "Game goes here\n";
    system("pause");
    }
    return 0;
    }

    [/CODE]

    i didn't understand what you meant walt

    Now in your main, set up a loop:

    code:--------------------------------------------------------------------------------
    do
    {
    ReadInputFromUser
    j = 0; // counter to get the command
    while (Commands[j] != "" && Commands[j] != inputline)
    j++;
    switch(j)
    {
    case SAVE:
    CallSaveFunction();
    break;
    case GAME:
    CallGameFunction();
    break;
    case EXIT:
    CallExitFunction();
    break;
    default:
    cout << "Illegal function" << endl;
    break;
    }
    } while (inputline != Commands[EXIT]);
    --------------------------------------------------------------------------------
    that should make it so i dont need

    Code:
     std::cin>>whattheytype2;
              }
              while(whattheytype2 != "game","theory") {
                  std::cout<<"I dont understand\n";                       
                  std::cin>>whattheytype2;
              }
              std::cout << "Game goes here\n";
              system("pause");
          }
    in 2 times right?
    Last edited by sreetvert83; 01-17-2004 at 04:14 PM.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Displaying Progress.
    By samus250 in forum C Programming
    Replies: 15
    Last Post: 04-11-2008, 03:56 PM
  2. Creating a progress window
    By Xzyx987X in forum Windows Programming
    Replies: 6
    Last Post: 10-06-2004, 04:02 PM
  3. progress bar newbie
    By WaterNut in forum Windows Programming
    Replies: 18
    Last Post: 08-09-2004, 01:42 PM
  4. Scaling Progress Steps :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 11-21-2002, 02:30 PM
  5. Progress Bars
    By knight543 in forum Windows Programming
    Replies: 1
    Last Post: 08-21-2002, 10:45 AM

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