I am not really having any problems with this. I'm just wondering if anybody has any ideas for a path for me to look down for bettering this little FF turn-based style of game in my free time.
I know somebody is going to complain about my global variables and the fact that I am not using object-oriented programming, but it will eventually get there. This is a boredom project that I'm plunking through.
Any advice or insight on any issues or ideas would be cool. And if somebody is looking into making a turn-based style of game, they can feel free to use up my code. Sorry about any bad formatting as well; I haven't really learned that yet.
// random.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
using namespace std;
int main()
{
int eHealth=100; //initial Enemy Health(based on enemy)
int pHealth=100; //initial Player Health
int eAttack=0; //Enemy Attack Strength(based on enemy)
int pAttack=0; //Player Attack Strength(based on level and items)
int selection=0; //Selection Variable for Battle Menue
int hPower=0; //Healing power Variable(random number)
int eSelection=0; //Enemies battle menu selection variable
int counter=0; //Counter to establish whos turn it is
int itemSelect=0; //Item inventory selection
int eMagic=50; //Enemies magic meter
int pMagic=50; //Players magic meter
cout<<pHealth<<" "<<eHealth<<endl; //player and enemy health levels
cout<<pMagic<<" "<<eMagic<<endl; //player and enemy magic levels
cout<<endl;
cout<<endl;
cout<<"1.Attack"<<endl; //lines 31-33 are the battle menu appears frequently throught game
cout<<"2.Heal"<<endl;
cout<<"3.Item"<<endl;
do //start of post test loop that runs the game until somebody is dead
{
if(counter==0)// if the counter variable is 0 it is the players turn
{
cin>>selection;
srand(static_cast<int>(time(0)));//randomize all the random variables
switch(selection)
{
case 1:// player chooses to ATTACK
pAttack=1+rand()%(35-1+1);//attack power can be between 1-35
cout<<"ATTACK "<<pAttack<<endl;
system("pause");
system("cls");
eHealth=eHealth-pAttack;
cout<<pHealth<<" "<<eHealth<<endl;
cout<<pMagic<<" "<<eMagic<<endl;
cout<<endl;
cout<<endl;
cout<<"1.Attack"<<endl;
cout<<"2.Heal"<<endl;
cout<<"3.Item"<<endl;
break;
case 2://Player chooses to heal, it costs 10 magic to heal so if you dont have enough magic you loose a turn
if(pMagic>9)
{
hPower=1+rand()%(35-1+1);//healing power can be any number between 1-35
cout<<"HEAL"<<hPower<<endl;
system("pause");
system("cls");
pHealth=pHealth+hPower;
pMagic=pMagic-10;
cout<<pHealth<<" "<<eHealth<<endl;
cout<<pMagic<<" "<<eMagic<<endl;
cout<<endl;
cout<<endl;
cout<<"1.Attack"<<endl;
cout<<"2.Heal"<<endl;
cout<<"3.Item"<<endl;
}//endIF
break;
case 3:// if player chooses to use item inventory system
cout<<"ITEM INVENTORY"<<endl;
cout<<"1.Potion Restores HP"<<endl;
cout<<"2.Ether Restores MP"<<endl;
cout<<"3.Bomb Causes Damage to all players"<<endl;
cout<<"4.Big Purple Dildo ?????"<<endl;
cout<<"5.Sticky Bomb Freezes oponent for 3 Truns"<<endl;
cin>>itemSelect;
switch(itemSelect)
{
case 1:
pHealth=pHealth+75;
system("cls");
cout<<pHealth<<" "<<eHealth<<endl;
cout<<pMagic<<" "<<eMagic<<endl;
cout<<endl;
cout<<endl;
cout<<"1.Attack"<<endl;
cout<<"2.Heal"<<endl;
cout<<"3.Item"<<endl;
break;
case 2:
break;
}//endItemSwitch
}//endSelectionSwitch
counter=1;// advances the counter to 1 to allow the enemies turn
}//endif
eSelection=rand() % 2+1;
switch(eSelection)
{
case 1:
eAttack=1+rand()%(35-1+1);
cout<<"ATTACK "<<eAttack<<endl;
system("pause");
system("cls");
pHealth=pHealth-eAttack;
cout<<pHealth<<" "<<eHealth<<endl;
cout<<pMagic<<" "<<eMagic<<endl;
cout<<endl;
cout<<endl;
cout<<"1.Attack"<<endl;
cout<<"2.Heal"<<endl;
cout<<"3.Item"<<endl;
break;
case 2:
if(eMagic>10)
{
hPower=1+rand()%(35-1+1);
cout<<"HEAL"<<hPower<<endl;
system("pause");
system("cls");
eMagic=eMagic-10;
eHealth=eHealth+hPower;
cout<<pHealth<<" "<<eHealth<<endl;
cout<<pMagic<<" "<<eMagic<<endl;
cout<<endl;
cout<<endl;
cout<<"1.Attack"<<endl;
cout<<"2.Heal"<<endl;
cout<<"3.Item"<<endl;
}
break;
}//endeSelectionSwitch
counter=0;
}while(eHealth > 1 && pHealth > 1);//loops while both players life is over 1 ends postest loop when players life or enemies falls below 1
system("pause");
return 0;
}
main()
. \$\endgroup\$