KiNgSGB

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

114 Neutral

About KiNgSGB

  • Rank
    Newbie
  1. Sorry I should have been more clear. The error is that once the user enters a input to choose whether or not to fight it just repeats that action. So over and over again no matter what the input is it just asks the user what they want to do.
  2. I've recently been learning c++ and I've been having trouble with game states. Here is my code. It is a text based rpg by the way. Not too complicated extremely basic.   http://codebin.org/view/06a657fb
  3. Thanks for all the help guys. I'm starting to understand a bit more about c++. Need some work on functions but I'll get there eventually.
  4. Ok so I understand what your saying there, but how do i declare each thing (gameIsRunning, IN_SHOP, EXPLORING, IN_SHOP). Sorry if it's a very noob question, but I'm still learning.
  5. Ok thanks but now the problem is the the switch goes through case 1 and 2. So instead of just killing the goblin and returning to the beginning, it also says you have died. How would I fix that.
  6. When I say this it is not a very good game at all. I actually have a problem that I need some input on. I know the error but I just don't know how to fix it. Here is the entire code     #include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main (int nNumberofArgs, char* pszArgs[]) {     char name[100];     cout<<"\t\tGreenwood"<< endl;     cout<<"Welcome stranger, what is your name?:"<< endl;     cin>>name;     cout<<"Welcome "<<name<<"\n";       cout<<"Please select a race: \n";     cout<<"1. Human \n";     cout<<"2. Orc \n";     int pickRace;     cout<<" Pick your race: ";     cin>>pickRace;       switch(pickRace)     {     case 1:         cout<<"You have chosen to be a human.\n";         break;     case 2:         cout<<"You have chosen to be an orc.\n";         break;     default:         cout<<"Invalid input, you many only select 1 or 2/.\n";     }       int difficulty;     cout<<"Select a difficulty: "<< endl;     cout<<"1.Easy"<< endl;     cout<<"2.Medium"<< endl;     cout<<"3.Hard"<< endl;       cout<<"Pick your difficulty: "<< endl;     cin>>difficulty;       switch(difficulty)     {     case 1:         cout<<"You have picked Easy."<< endl;         break;     case 2:         cout<<"You have picked Medium."<< endl;         break;     case 3:         cout<<"You have picked Hard."<< endl;         break;     default:         cout<<"Invalid input."<< endl;         break;     }       int choice;     int attack = 2;     int cHealth;     int eHealth = 8;     int yn;     int stats;     int looper = 7;       while (looper > 1)     {     cout<<"Select a command: "<< endl;     cout<<"1.Fight"<< endl;     cout<<"2.Stats"<< endl;     cout<<"Select: ";     cin>>choice;       switch (choice)     {     case 1:         cout<<"Attacked by a Goblin! Attack back?"<< endl;         cout<<"1.Yes"<< endl;         cout<<"2.No"<< endl;         cin>>yn;         switch (yn)         {         case 1:             while (eHealth > 0)             {             eHealth - attack;             if (eHealth <= 0)             {                  cout<<"You have killed the goblin."<< endl;             cout<< endl;             ++stats;             break;             }             }           case 2:             cout<<"You have died."<< endl;             break;         }         break;       case 2:         cout<<"Level "<<stats<< endl;         cout<<" "<< endl;         cout<<" "<< endl;         break;               }                     } }           The problem is at:      cout<<"Select a command: "<< endl;     cout<<"1.Fight"<< endl;     cout<<"2.Stats"<< endl;     cout<<"Select: ";     cin>>choice;       switch (choice)     {     case 1:         cout<<"Attacked by a Goblin! Attack back?"<< endl;         cout<<"1.Yes"<< endl;         cout<<"2.No"<< endl;         cin>>yn;         switch (yn)         {         case 1:             while (eHealth > 0)             {             eHealth - attack;             if (eHealth <= 0)             {                  cout<<"You have killed the goblin."<< endl;             cout<< endl;             ++stats;             break;             }             }           case 2:             cout<<"You have died."<< endl;             break;         }         break;       case 2:         cout<<"Level "<<stats<< endl;         cout<<" "<< endl;         cout<<" "<< endl;         break;               }     If I take out the part with while (eHealth > 0). I can get it to work fine, but I would like a health system. I need some help with the health system. By the way I'm also pretty new to programming so I may not understand some terms.
  7. Text Based RPG

    I fixed it but then right after entering the name it doesn't let me input the choice value. It just says "Press Key to Continue". Which then exits me out. Here is the updated one.     #include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main (int nNumberofArgs, char* pszArgs[]) {     int name;     int classs;     int choice = 0;     cout <<"What is your name stranger?"     <<endl;     cin >>name;       cout <<"Choose a class:"<< endl;     cout <<"1. Warrior"<< endl;     cout <<"2. Mage"<< endl;     cout <<"3. Rogue"<< endl;     cout <<"4. Cleric"<< endl;     cin >>choice;     system("PAUSE");       switch (choice)     {     case '1':         cout <<"You have chosen to be a warrior.";         break;     case '2':         cout <<"Yoy have chosen to be a mage.";         break;     case '3':         cout <<"You have chosen to be a rogue.";         break;     case '4':           cout <<"You have chosen to be a cleric.";         break;     }     system("PAUSE");     return 0;     }
  8. I'm fairly new to programming and I'm making a text based RPG as I learn. I have the part where it asks for your name but the problem is when selecting a class. Instead of allowing the user to input and having the console reply, it ends the program. Here is the code. Any help would be appreciated.     #include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main (int nNumberofArgs, char* pszArgs[]) {     int name;     int classs;     int choice;     cout <<"What is your name stranger?"     <<endl;     cin >>name;     cout <<"Choose a class:"<< endl;     cout <<"1. Warrior"<< endl;     cout <<"2. Mage"<< endl;     cout <<"3. Rogue"<< endl;     cout <<"4. Cleric"<< endl;     cin >>choice;     system("PAUSE");       switch (classs)     {     case '1':         cout <<"You have chosen to be a warrior.";         break;     case '2':         cout <<"Yoy have chosen to be a mage.";         break;     case '3':         cout <<"You have chosen to be a rogue.";         break;     case '4':           cout <<"You have chosen to be a cleric.";         break;     }     system("PAUSE");     return 0;     }