its a little text fighting game.
it's almost impossible to lose but still its not to bad i don't think.
#include <iostream>
using namespace std;
#include <cstdlib>
#include <limits>
void CAPP_Stay(int);
int store(int,int,int);
int main(){
int character = 0,
get,
attack = 100,
range = 100,
Epos[5],
Eattack[5],
oldmoney = 0,
money = 100,
enemy = 0;
float health = 100,
enemyhealth[6] = { 100.0 , 100.0 , 100.0 , 100.0 , 100.0 , 100.0 };
cout << "Enter Character type\n" << "1 for Mage, 2 for Archer, 3 for Swordsmen, and 4 for Theif\nCharacter Type>";
cin >> get;
switch (get)
{
case 1:
character = 1;
cout << "You're a Mage!\nYour Attack is increased!\n\n";
attack = attack + 15;
break;
case 2:
character = 2;
cout << "You're a Archer!\nYour Range is increased!\n\n";
range = range + 50;
break;
case 3:
character = 3;
cout << "You're a Swordsmen!\nYour Attack is greatly increased!\nBut Range is decreased\n\n";
attack = attack + 25;
range = range - 15;
break;
case 4:
character = 4;
cout << "You're a Theif!\nYou Will get more money when attacking\nYour Staring money is also increased!\n\n";
money += 50;
default:
break;
}
for (int x = 1 ; x < 6 ; ++x){
Epos[x] = 1 + rand() % 150;
Eattack[x] = 1 + rand() % 200;
cout << "Enemy " << x << ":\nHealth> " << enemyhealth[x] << " "
<< "Position> " << Epos[x] << " "
<< "Attack> " << Eattack[x] << endl << endl;
}
int end = 0;
enemy = 1;
cout << endl << "Your Health>" << health << ", Range>" << range << ", Attack>" << attack << ", Money>" << money << endl
<< "Enemy Health>" << enemyhealth[enemy] << ", Position>" << Epos[enemy] << ", Attack>" << Eattack[enemy] << endl << endl;
while ( end == 0 ){
cout << "Attack Enemy(Press 6 to Goto store)> ";
cin >> enemy;
if (enemy == 6){
oldmoney = money;
money = store(money,range,attack);
if (oldmoney - money == 65)
attack = attack + 15;
if (oldmoney - money == 75)
range = range + 15;
if (oldmoney - money == 100)
health = 100;
}
if (Epos[enemy]<range){
if (attack>Eattack[enemy]){
enemyhealth[enemy] = enemyhealth[enemy] - 15;
if (enemyhealth[enemy] < 0)
enemyhealth[enemy] = 0;
Eattack[enemy] = Eattack[enemy] - 5;
if (character < 4)
money = money + 5;
else
money = money + 15;
}
else{
health = health - 15;
attack = attack -5;
if (health < 0)
health = 0;
}
}
else{
cout << "You can't attack that enemy" << endl
<< "He is out of range" << endl;
}
for (int x = 1 ; x < 6 ; ++x){
cout << "Enemy " << x << ":\nHealth> " << enemyhealth[x] << " "
<< "Position> " << Epos[x] << " "
<< "Attack> " << Eattack[x] << endl << endl;
}
cout << endl << "Your Health>" << health << ", Range>" << range << ", Attack>" << attack << ", Money>" << money << endl
<< "Enemy Health>" << enemyhealth[enemy] << ", Position>" << Epos[enemy] << ", Attack>" << Eattack[enemy] << endl << endl;
if (enemyhealth[enemy] <= 0 || health <= 0 ){
if (enemy < 6)
end=1;
}
}
if (health > 0)
CAPP_Stay(1);
else
CAPP_Stay(0);
return 0;
}
void CAPP_Stay(int win) {
if (win == 1)
cout << endl << "You Win Press Return to Continue";
else
cout << endl << "You Loose Press Return to Continue";
cin.clear(); //clear cin so its in good.
//read to next newline ignoring everything it reads, also handy for clearing garbage from a streem.
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cin.get();
}
int store(int money,int range,int attack){
cout << "Welcome to the store!" << endl
<< "Heres What I've got." << endl
<< "1. Upgrade Attack> $65" << endl
<< "2. Upgrade Range> $75" << endl
<< "3. Heal Character> $100" << endl;
int selection;
cout << "Selection> ";
cin >> selection;
switch (selection){
case 1:
money = money - 65;
break;
case 2:
money = money - 75;
break;
case 3:
money = money - 100;
break;
}
return money;
}
New Site! Check it out \/