I am making my first text based game. When I show the code please don't gasp at how horribly I organize my code. I know it is bad, but that isn't the issue. I checked my last function but every time I try to build and compile it, it gives me this error-
"1>c:\documents and settings\owner\my documents\visual studio 2005\projects\textbasedgame\textbasedgame\textgame .cpp(167) : error C2059: syntax error : '}'"
This shows an error on the last line of the code
here is the code:
Please helpCode:#include<iostream> #include<time.h> #include<cstring> #include<string> using namespace std; int lvl; int experience; int base; int action; int damage; int magicdamage; string type; int money = 500; string gender; int health = 100; int excess; string name; void goblinbattle(); int battleaction; string battleaction2; int wis = 5; int str = 5; int agi = 5; int main() { int gender1; cout<<"Welcome to the world of Leflorin.\n"; cout<<"Here you will fight evil monsters and become powerful.\n"; cout<<"You fight for your nation, you fight to bring down the evil Scylla!\n"; cout<<"Are you ready... \n"; system("PAUSE"); while(base > 3 || base < 1) { system("cls"); cout<<"Choose your base stat: \n"; cout<<"1. Wizard: Powerful in all magics\n"; cout<<"2. Warrior: Powerful with all weapons\n"; cout<<"3. Thief: Quick and nimble\n"; cout<<"Choose now... "; cin>>base; if(base > 3 || base < 1 || !base) { cout<<"Incorrect entry"; cin.clear(); cin.ignore(80, '\n'); } } switch(base) { case 1: { wis++; type = "wizard"; } break; case 2: { str++; type = "warrior"; } break; case 3: { agi++; type = "Thief"; } break; default: { cout<<"Incorrect entry"; } break; } system("cls"); cout<<"Congratulations, after much hard work, you have become a "<<type<<"!\n"; cout<<"Your stats are now: \n"; cout<<"wisdom: "<<wis<<"\nStrength: "<<str<<"\nAgility: "<<agi<<"\n"; system("PAUSE"); system("cls"); cin.clear(); cin.ignore(80, '\n'); cout<<"Now choose your gender:\n1. Male\n2. Female\n"; cin>>gender1; if(!gender1) { cout<<"Incorrect entry."; cin.clear(); cin.ignore(80, '\n'); } switch(gender1) { case 1: { gender = "Male"; } break; case 2: { gender = "Female"; } break; default: { cout<<"Incorrect entry."; } } cout<<"Now that we know your a "<<gender<<", we need to know\nwhat your name is.\n"; cin>>name; cout<<"\n"; cout<<"What a powerful name, "<<name<<" is!\n"; system("cls"); cout<<"Lets review your information:\nType:\n "<<type<<"\nGender:\n "<<gender<<"\nName:\n "<<name<<"\n"; cout<<"Now you are ready to begin your struggle!"; system("PAUSE"); system("cls"); cout<<"You lie on a cot in your barn after many hours of hard work. When you wake up you hear\na crackle as if something is burning..."; cout<<"\nYou hasten to the door where you see a goblin with a torch.\nYour whole house is a giant, smoldering, decayed pile of ash.\n"; cout<<"The goblin turns to look at you, his eyes a dull grey.\nYou slowly draw your sword, deep inside yourself\nyou draw on your abilities."; cout<<"Anger, hate, revenge swells up inside of you!\nIt is time to fight\n"; system("PAUSE"); goblinbattle(); system("PAUSE"); return 0; } void goblinbattle() { do { srand ( time(NULL) ); damage = rand() % str + 1; magicdamage = rand() % wis + 1; int gobstr = 4; int gobhealth; gobhealth = 25; cout<<"Choose your action: \n"; cout<<"1. Melee\n2. Magic\n3. Rest\n"; cin>>battleaction; switch(battleaction) { case 1: { action = rand() % 100 + 1; if(action <= (35 - str)) { cout<<"You miss the enemy with your sword.\n"; cout<<"The enemy has "<<gobhealth<<" health left.\n"; } else { cout<<"You cut deep into the enemy.\n"; cout<<"You do " <<damage<<" damage to the enemy.\n"; cout<<"He has " <<(gobhealth - damage)<<" health left.\n"; } } break; default: { cout<<"Incorrect entry"; } break; } } }//here



LinkBack URL
About LinkBacks


