Write your question here.
I am having issues with my program in which it doesn't actually change the value of my variables in my classes so that I can then use in my battlesequence. This snippet is the function where i'd like to use them. I'm pretty tying to have it kill the loop once the enemy is dead by checking to see if the enemy is dead. This isn't finished it just basic and will probably need a lot more work.. I don't wanna put the rest of the code as it'll be a huge chunk soo yeah. Unless I have to then i might.
void enemyHealth(float damage)
{
enemy1Hp = enemy1Hp - damage;
if (enemy1Hp > 0)
{
cout << "The enemy now has " << enemy1Hp << endl;
}
else
{
cout << "You have slain the enemy " << endl;
enemies typeE;
typeE.setBandit(1);
}
}
//This is for the battle moments with the enemys.
int battleSequence(void)
{
while (true)
{ //srand(time(NULL));
int playerChoice;
int gameAttack = rand() % 4 + 1;
float damageC;
int taunt = rand() % 2 + 1;
int ragey = rand() % 2 + 1;
bool wuuthrad;
string rage;
string twant;
enemies typeE;
cout << typeE.getOrc();
if (typeE.getOrc() <= 0){
break;
}
//This is my class that i'm using to change and set values and stuff...
#pragma once
class enemies {
public:
enemies();
~enemies();
void setBandit(float BanditN) {
Bandit = BanditN;
}
float getBandit() {
return Bandit;
}
void setMage(float MageN) {
Mage = MageN;
}
float getMage() {
return Mage;
}
void setOrc(float OrcN) {
Orc = OrcN;
}
float getOrc() {
return Orc;
}
void setDarkMage(float DarkMageN) {
darkMage = DarkMageN;
}
float getDarkMage() {
return darkMage;
}
void setKingRagnok(float KingRagnokN) {
KingRagnok = KingRagnokN;
}
int getKingRagnokN() {
return KingRagnok;
}
/* Using the object in private in public, thus keeping them secure and being
able to keep them secure by only using them in public to manipulate them for my main*/
private:
float Bandit = 10;
float Mage = 15;
float Orc = 20;
float darkMage = 18;
float KingRagnok = 30;
};
if your still here could you please help me man? I've been trying to use pointers and pass by reference but i've been having a load of problems.. I'm a noob so could you possibly help me with my code in where I can pass by reference?