Ok I am making a simple texed based rpg. I know I did a long way and didn't use some of the stuff I should have and please don't comment on that.
The long code...
Code:#include <iostream.h> #include <conio.h> #include <cstdlib> #include <string.h> using namespace std; int P_health; int P_level; int P_attack; int P_def; int P_weapon; int P_magic; int P_race; int P_totaldamage; int P_dead; int E_health; int E_attack; int E_def; int E_magic; int E_alreadyset; int E_totaldamage; int E_dead; int goagain; int mainmenu; int gamemenu; int show; int main() { goagain=0; P_dead=0; E_dead=0; gamemenu=0; show=0; mainmenu=1; while(mainmenu==1) { mainmenu=0; show=0; cout<<"1. Create Player\n"; cout<<"2. Test Battle\n"; cin>>gamemenu; if(gamemenu==1) if(show==0) { show=1; cout<<"\n\n\nWhat do you want to be?"; cout<<"\n\n\n1. Warrior"; cout<<"\n2. Knight"; cout<<"\n3. Sorcerer\n"; cin>>P_race; cout<<"\n\n\nYou have choosen "<<P_race; getch(); if(P_race==1) { P_level=1; P_health=50; P_attack=6; P_def=4; P_weapon=1; P_magic=0; } system("CLS"); mainmenu=1; } if(gamemenu==2) if(show==0) { show=1; system("CLS"); cout<<"Battle Begin!!!\n\n\n\n"; if(E_alreadyset==0) { E_health=20; E_attack=7; E_def=2; E_magic=0; E_alreadyset=1; } P_totaldamage=(P_attack-E_def); E_totaldamage=(E_attack-P_def); do //I want it to loop from here... { cout<<"Your attack...\n\n\n\n"; getch(); E_health=E_health-(P_attack-E_def); cout<<"You did "<<P_totaldamage<<" damage"; getch(); cout<<"\n\n\n\n"; cout<<"Enemy's attack..\n\n\n\n"; getch(); P_health=P_health-(E_attack-P_def); cout<<"The enemy did "<<E_totaldamage<<" damage to you"; getch(); if(P_health<1) { P_dead=1; } if(E_health<1) { E_dead=1; } if(E_dead=1) { system("CLS"); mainmenu=1; } if(P_dead=1) { system("CLS"); mainmenu=1; } }while(E_dead==0); //to here, this would be the end of the loop. } if(gamemenu==100) if(show==0) { show=1; cout<<P_health<<"\n"<<E_health; getch(); system("CLS"); mainmenu=1; } } getch(); return 0; }