ok i am just learning c++ and decided to make a little text adventure but when i use a for loop to setup the 5 enemies it doesn't do it. i don't know why though. heres the code:
#include <iostream>
using namespace std;
#include <cstdlib>
#include <limits>
void CAPP_Stay();
int main(){
int character = 0,
enemy[ 5 ] = { 0 , 0 , 0 , 0 , 0 },
get,
attack = 100,
range = 100,
Epos[5],
Eattack[5];
float health = 100,
enemyhealth[5] = { 100 , 100 , 100 , 100 , 100 };
cout << "Enter Character type\n" << "1 for mage, 2 for archer, 3 for swordsmen\n";
cin >> get;
switch (get)
{
case 1:
character = 1;
cout << "Your a Mage!\nYour Attack and defence are increased!\n";
attack = attack + 15;
break;
case 2:
character = 2;
cout << "Your a Archer!\nYour Range is increased!\nBut your defence is decreased\n";
range = range + 15;
break;
case 3:
character = 3;
cout << "Your a Swordsmen!\nYour Attack is greatly increased!\nBut Range is decreased\n";
attack = attack + 25;
range = range - 15;
break;
default:
break;
}
for (int x = 0 ; x > 5 ; ++x){
enemy[x] = 1 + rand() % 5;
Epos[x] = 1 + rand() % 150;
Eattack[x] = 1 + rand() % 115;
}
for (int x = 0 ; x > 5 ; x++){
cout << "Enemy " << x << ":\nHealth> " << enemyhealth[x] << endl
<< "Position> " << Epos[x] << endl
<< "Attack> " << Eattack[x] << endl;
}
cout << enemy[1];
CAPP_Stay();
return 0;
}
void CAPP_Stay() {
cout << endl << "PAUSED: 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();
}
ideas?
New Site! Check it out \/