I'm going to show you all a game i made a while back. Yes, i am aware of the bad spacing and i made it a while ago.
Please tell me what you want me to add and i will try my best to do so.
Save as "Game Main File.cpp"
Here is "All.h" Please save as so.Code:#include "All.h" using namespace std; int main() { string name; // Your Character Name cout << "Please enter your name" << endl; cin >> name; while (turn = 1) { system("cls"); cout << "********************************************************************************\n"; cout << "* *\n"; cout << "* Untold Rewritten Stories *\n"; cout << "* *\n"; cout << "********************************************************************************\n"; cout << "Welcome " << name << endl; cout << "Please select what you wish to do:" << endl; if(level == 1) { pct = exp / lvl1 * 100; } if (level == 2) { pct = (exp / 175) * 100; } if (level == 3) { pct = (exp / 250) * 100; } if (level == 4) { pct = (exp / 300) * 100; } if (level == 5) { pct = (exp / 400) * 100; } if (level == 6) { pct = (exp / 500) * 100; } if (level == 7) { pct = (exp / 600) * 100; } if (level == 8) { pct = (exp / 700) * 100; } if (level == 9) { pct = (exp / 1000) * 100; } cout << "Your current level is " << level << ", you have " << exp << " exp points. You are at " << pct << "%\n"; if (level == 1 & exp >= 100) { cout << "LEVEL UP! TYPE 10 TO LEVEL UP!\n"; } if (level == 2 & exp >= 175) { cout << "LEVEL UP! TYPE 10 TO LEVEL UP!\n"; } if (level == 3 & exp >= 250) { cout << "LEVEL UP! TYPE 10 TO LEVEL UP!\n"; } if (level == 4 & exp >= 300) { cout << "LEVEL UP! TYPE 10 TO LEVEL UP!\n"; } if (level == 5 & exp >= 400) { cout << "LEVEL UP! TYPE 10 TO LEVEL UP!\n"; }if (level == 6 & exp >= 500) { cout << "LEVEL UP! TYPE 10 TO LEVEL UP!\n"; }if (level == 7 & exp >= 600) { cout << "LEVEL UP! TYPE 10 TO LEVEL UP!\n"; }if (level == 8 & exp >= 700) { cout << "LEVEL UP! TYPE 10 TO LEVEL UP!\n"; }if (level == 9 & exp >= 1000) { cout << "LEVEL UP! TYPE 10 TO LEVEL UP!\n"; } cout << "1. Fight" << endl; cout << "2. Rest (25 gold)" << endl; cout << "3. Equip\n"; cout << "4. Save\n"; cout << "5. Load\n"; cout << "6. Exit\n"; int choice; cin >> choice; switch(choice) { case 1: { system("cls"); cout << "********************************************************************************\n"; cout << "* *\n"; cout << "* Attack Sequence *\n"; cout << "* *\n"; cout << "********************************************************************************\n"; cout << "Please choose the monster you wish to attack\n"; cout << "1. Walking Mushroom\n"; cout << "2. Poison Mushroom\n"; if(level >= 3) cout << "3. Bunny\n"; if (level >= 5) cout << "4. Vicious Bunny\n"; cout << "5. Exit\n"; int mon; cin >> mon; switch(mon) { case 1: while(wm > 0 & UHP > 0) { system("cls"); cout << "The walking Mushroom attacks!\n"; UHP = UHP - (wmd1 - (dp / 3)); cout << endl; cout << "You now have " << UHP << " Health Points left!\n"; system("pause"); system("cls"); cout << "You attack the Walking Mushroom doing " << dmg << " Damage!\n"; wm = wm -dmg; cout << "The Walking Mushroom now has " << wm << " Health Points Left\n"; system("pause"); }if(wm <= 0){ system("cls"); cout << "You have killed the Walking Mushroom earning you:\n"; cout << " 25 exp\n"; cout << " 25 gold\n"; cout << " 1 Stick\n"; cout << " 1 Cloth\n"; cout << " 1 pair of Pants\n"; money = money + 25; exp = exp + 25; stick = stick + 1; cloth = cloth + 1; pants = pants + 1; wm = 100; system("pause"); } else if (UHP <= 0) { cout << "You have been killed by the Walking Mushroom!\nPlease work harder and pay more attention in the future.\n"; cout << "\n\nGame Over\n"; system("pause"); return 0; } break; case 2: while(pm >= 0 & UHP >= 0) { system("cls"); cout << "The Poison Mushroom attacks!\n"; UHP = UHP - (pmd1 - (dp / 3)); cout << "You now have " << UHP << " Health Points left!\n"; system("pause"); system("cls"); cout << "You attack the Poison Mushroom doing " << dmg << " Damage!\n"; pm = pm - dmg; cout << "The Poison Mushroom now has " << pm << " Health Points Left\n"; system("pause"); }if(pm <= 0){ system("cls"); cout << "You have killed the Poison Mushroom earning you:\n"; cout << " 30 exp\n"; cout << " 32 gold\n"; cout << " 1 Stick\n"; cout << " 1 Cloth\n"; cout << " 1 pair of Pants\n"; cout << " 1 pair of Shoes\n"; money = money + 32; exp = exp + 30; stick = stick + 1; cloth = cloth + 1; pants = pants + 1; shoes = shoes + 1; pm = 100; system("pause"); } if (UHP <= 0) { cout << "You have been killed by the Poison Mushroom!\nPlease work harder and pay more attention in the future.\n"; cout << "\n\nGame Over\n"; system("pause"); return 0; } break; case 3: if (level >= 3) { while (b > 0 & UHP > 0) { system("cls"); cout << "The bunny attacks!\n"; UHP = UHP - (bd1 - (dp / 3)); cout << "You now have " << UHP << " Health Points left!\n"; system("pause"); system("cls"); cout << "You attack the Bunny doing " << dmg << " Damage!\n"; b = b - dmg; cout << "The Bunny now has " << b << " Health Points Left\n"; system("pause"); }if(b <= 0){ system("cls"); cout << "You have killed the Bunny earning you:\n"; cout << " 45 exp\n"; cout << " 41 gold\n"; cout << " 1 Stick\n"; cout << " 1 Cloth\n"; cout << " 1 pair of Pants\n"; cout << " 1 pair of Shoes\n"; cout << " 1 Shield\n"; money = money + 41; exp = exp + 45; stick = stick + 1; cloth = cloth + 1; pants = pants + 1; shoes = shoes + 1; shield = shield + 1; b = 100; system("pause"); } if (UHP <= 0) { cout << "You have been killed by the Bunny!\nPlease work harder and pay more attention in the future.\n"; cout << "\n\nGame Over\n"; system("pause"); return 0; } } else { cout << "Sorry " << name << ", you are not yet a high enough level to attack the Bunny\n"; system("pause"); } break; case 4: if (level >= 5) { while (vb > 0 & UHP > 0) { system("cls"); cout << "The Vicious Bunny attacks!\n"; UHP = UHP - vbd1; cout << "You now have " << UHP << " Health Points left!\n"; system("pause"); system("cls"); cout << "You attack the Vicious Bunny doing " << dmg << " Damage!\n"; vb = vb - dmg; cout << "The Vicious Bunny now has " << vb << " Health Points Left\n"; system("pause"); }if(b <= 0){ system("cls"); cout << "You have killed the Bunny earning you:\n"; cout << " 58 exp\n"; cout << " 81 gold\n"; cout << " 1 Sword\n"; money = money + 81; exp = exp + 58; sword = sword + 1; vb = 100; system("pause"); } if (UHP <= 0) { cout << "You have been killed by the Vicious Bunny!\nPlease work harder and pay more attention in the future.\n"; cout << "\n\nGame Over\n"; system("pause"); return 0; } }else { cout << "Sorry " << name << ", you are not yet a high enough level to attack the Bunny\n"; system("pause"); } break; default: { cout << "You didn't make a valid choice\n"; system("cls"); } } } break; case 2: { system("cls"); cout << "********************************************************************************\n"; cout << "* *\n"; cout << "* Inn *\n"; cout << "* *\n"; cout << "********************************************************************************\n"; cout << "\n"; cout << "1. Stay a night? (25 gold)\n"; cout << "2. Leave\n"; int inn; cin >> inn; if(inn = 1) { if(money >= 25) { cout << "Let me show you to your room\n"; money = money - 25; UHP = 100; UMP = 20; } else { cout << "Sorry " << name << ", you don't have the required money\n"; system("pause"); } } else { cout << "Thank you anyways\n"; system("pause"); } } break; case 3: { system("cls"); cout << "********************************************************************************\n"; cout << "* *\n"; cout << "* Equipment *\n"; cout << "* *\n"; cout << "********************************************************************************\n"; cout << "The equipment below is what you have obtained\n"; cout << " Items can only be worn once.\n\n"; if (stick >= 1 & stickuse == 0) { cout << "Stick \n"; } if (sword >= 1) { cout << "Sword \n"; } if (shirt >= 1) { cout << "Shirt \n"; } if (cloth >= 1) { cout << "Cloth \n"; } if (shield >= 1) { cout << "Shield \n"; } if (pants >= 1) { cout << "Pants \n"; } if (shoes >= 1) { cout << "Shoes \n"; } cout << "\n\n"; cout << "1. Equip these items\n"; int Equip; cin >> Equip; if (Equip = 1) { if (stick >= 1 & stickuse == 0) { dmg = dmg + 7; stick--; stickuse++; }else if (stickuse >= 1) { cout << "You already have a stick equipped\n\n"; } if (cloth >= 1 & clothuse == 0) { dp = dp + 5; cloth--; clothuse++; }else if (clothuse >= 1) { cout << "You already have a cloth equipped\n\n"; } if (shield >= 1 & shielduse == 0) { dp = dp + 5; dmg = dmg + (2); shield--; shielduse++; }else if (shielduse >= 1) { cout << "You already have a shield equipped\n\n"; } if (pants >= 1 & pantsuse == 0) { dp = dp + (2); pants--; pantsuse++; }else if (pantsuse >= 1) { cout << "You already have pants equipped\n\n"; } if (shoes >= 1 & shoesuse == 0) { dp = dp + (1); dmg = dmg + (1); shoes--; shoesuse++; }else if (shoesuse >= 1) { cout << "You already have shoes equipped\n\n"; } if (sword >= 1 & sworduse == 0) { dmg = dmg + (13); sword--; sworduse++; }else if (sworduse >= 1) { cout << "You already have a sword equipped\n\n"; } } system("pause"); } break; case 4: // Save { ofstream save("Save.dll"); save << name << endl; save << UHP << endl; save << UMP << endl; save << money << endl; save << level << endl; save << exp << endl; save << dp << endl; save << dmg << endl; save << stick << endl; save << cloth << endl; save << shield << endl; save << pants << endl; save << shoes << endl; save.close(); cout << "Done!\n"; system("pause"); } break; case 5: // Load { ifstream save("Save.dll"); save >> name >> UHP >> UMP >> money >> level >> exp >> dp >> dmg >> stick >> cloth >> shield >> pants >> shoes; cout << "Done!\n"; system("pause"); } break; case 6: { cout << "Thank you for playing\n"; cout << "Game created and coded by Black Nemo\n"; system("pause"); return 0; } break; case 10: if (exp >= 100) { system("cls"); cout << "********************************************************************************\n"; cout << "* *\n"; cout << "* Level Up *\n"; cout << "* *\n"; cout << "********************************************************************************\n"; if (level == 1 & exp >= 100) { cout << "Congrats you have leveled:\n"; exp = exp - 100; level = level + 1; dmg = dmg + 1; } else if (level == 2 & exp >= 175) { cout << "Congrats you have leveled:\n"; exp = exp - 175; level = level + 1; dmg = dmg + 2; } else if (level == 3 & exp >= 250) { cout << "Congrats you have leveled:\n"; exp = exp - 250; level = level + 1; dmg = dmg + 3; } else if (level == 4 & exp >= 300) { cout << "Congrats you have leveled:\n"; exp = exp - 300; level = level + 1; dmg = dmg + 4; } else if (level == 5 & exp >= 400) { cout << "Congrats you have leveled:\n"; exp = exp - 400; level = level + 1; dmg = dmg + 5; } else if (level == 6 & exp >= 500) { cout << "Congrats you have leveled:\n"; exp = exp - 500; level = level + 1; dmg = dmg + 6; } else if (level == 7 & exp >= 600) { cout << "Congrats you have leveled:\n"; exp = exp - 600; level = level + 1; dmg = dmg + 7; } else if (level == 8 & exp >= 700) { cout << "Congrats you have leveled:\n"; exp = exp - 700; level = level + 1; dmg = dmg + 8; } else if (level == 9 & exp >= 1000) { cout << "Congrats you have leveled:\n"; exp = exp - 1000; level = level + 1; dmg = dmg + 9; } else { cout << "Sorry " << name << " you do not have the needed exp to level up\n"; } }else { cout << "You need at least 100 exp to view this screen\n"; system("pause"); } system("pause"); break; default: { cout << "Please enter a valid option\n"; system("pause"); } } } }
This needs work, that is why i didn't put it in the showcase forum.Code:#include <windows.h> #include <iostream> #include <string> #include <fstream> int UHP = 100; // your health points int UMP = 20; // Your Mana Points int money = 100; // Your money int level = 1; //You Level int exp = 0; // Your Exp int dp = 1; //level exp int lvl1 = 100; int lvl2 = 175; int lvl3 = 250; int lvl4 = 300; int lvl5 = 400; int lvl6 = 500; int lvl7 = 600; int lvl8 = 700; int lvl9 = 1000; // Monsters. int wm = 100; //Walking Mushroom HP int pm = 100; //Poison Mushroom HP int b = 100; //Bunny HP int vb = 150; //Vicious Bunny HP // Percentage int pct = 0; // User Damage; int dmg = 10; // User items; int stick = 0; int stickuse = 0; int cloth = 0; int clothuse = 0; int shield = 0; int shielduse = 0; int pants = 0; int pantsuse = 0; int shoes = 0; int shoesuse = 0; int sword = 0; int sworduse = 0; int shirt = 0; int shirtuse = 0; // Who's Turn is it? int turn = 1; // Walking Mushroom Damage int wmd1 = 5; //Poison Mushroom Damage int pmd1 = 8; //Bunny Damage int bd1 = 13; //Vicious Bunny Damage int vbd1 = 20;
The Attachment contains both the game and the files.
--Alex


Reply With Quote![[C++] Game!](http://ragezone.com/hyper728.png)


