Thread: A little help here?

  1. #1
    Registered User
    Join Date
    Apr 2006

    A little help here?

    #include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;
    int place;
    int gold = 100;
    int level = 1;
    int main ()
        cout<< "Where do you want to go?\n\n\n1. Castle\n2. Weapons shop\n3. Old man on street\n4. DRAGONS LAIR(!)\n\n(!) = Danger zone, level 5 minimum.\n\n";
        cin>> place;
        switch (place) {
               case 1:
                    cout<< "CONGRATULATIONS!!! YOU ARE NOW LEVEL 2!!!\n\n\n\nWhat do you want to do?\n\n\n11 Speak to Knight\n12 Enter kings bedroom\n\n";
                    cin>> place;
                    level = 2;
                    if (place == 11) {
                              cout<< "The Knight gives you 300 bronze, you hear something equavilent to: 'kill the drag...', hmm, I wonter what he means.";
               case 2:
                    cout<< "The weapon shop keeper asks you if you want to buy the powerful sword Drfil...\n\n\n\nWhat do you want to do?\n\n\n1. 'I accept.'\n2. 'I don't want your junk.'\n3. 'I cant afford it.'\n4. 'It costs 400 bronze right? I'll be back, sir.'\n\n-=PRICES=-\n1. Bronze sword: 20 bronze\n2. Silver sword: 50 bronze\n3. Knights sword: 200 bronze\n4. Drfil\n\n";
               case 3:
                    cout<< "Suddenly an old man comes up and asks for a fight, what will you do?!?\n\n\n1. Fight back\n2. Run!\n3. Decline.\n\n";
               case 4:
                    if (level != 5) {
                       cout<< "MUST BE LEVEL 5 TO ENTER!!!";
                    else {
                        cout<< "Welcome, you are ready to fight the dragon.\n\n";
    As you may have noticed, it's my source code for a RPG. It works fine, but when you go to the castle there are two options, 1.1 (11) or 1.2 (12), now, when I press 11, it is supposed to go to the knight, but it doesn't, and I need to know how to make it go back to 1 without making it say "CONGRATULATIONS!", any help would be apreciated. (SP?)

  2. #2
    C / C++
    Join Date
    Jan 2006
    The Netherlands
    I don't see

    case 11:
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  3. #3
    Registered User
    Join Date
    Jan 2005
    >> if (place == 11) {
    Where is the closing brace for that?

    >> I need to know how to make it go back to 1
    Use a loop and add a case for 11.

Popular pages Recent additions subscribe to a feed