How to adjust class objects through seperate class functions???
I want to create a battle system for an RPG game, one a little more robust then the previous one I made. This one I want to be very dynamic and easy to use. I want to use the Allegro API for it, but first I want to make sure I have everything going good in console before I put it into a real time rpg, but I'm having technical difficulties...
Now here are my classes...
class Game{
};
class Boxer:Game{
public:
char name[256];
int health, *attack, level, critchance,xp,requiredxp;
int Attack(){return -(*attack-rand()%(level/2));}
void setName(){}
void AdjustXP(int x){xp+=x;}
void Spash(){printf("HP:%d\tXP:%d/%d\n",health,xp,requiredxp);}
void EveryFrame(){*attack=level*3;}
Boxer(){health=25;level=15;requiredxp=level*5,xp=0;}
};
class Battle:Game{
public:
void Attack(int attackerhit, int * attackeehp){*attackeehp+=attackerhit;}
};
int main(){
srand(time(NULL));
Boxer Boxer;
Battle Battle;
int attack=5;
Battle.Attack(attack,Boxer->hp) //??? Heres my problem I believe
cout<<Boxer.hp;
}
Right now I want to pass the Boxer class' HP through a pointer to the Battle Classes Attack function, while passing a normal int (since the attack really doesnt need to be adjusted as of now). I get really weird errors like no matching function for call to `Battle::Battle(int&, int)'|... Please help!!!
Manutebecker
Junior Poster in Training
51 posts since May 2008
Reputation Points: 10
Solved Threads: 3
so far ty, however i have 2 questions, I dont know why I need a const in there, and I cant find any really helpful tuts on polymorphism and class deriving, can you lead me to a good one :P
Manutebecker
Junior Poster in Training
51 posts since May 2008
Reputation Points: 10
Solved Threads: 3
ugh can you just show me what you would do in the int main() too I'm really having severe problems, me and pointers are just not friends
Manutebecker
Junior Poster in Training
51 posts since May 2008
Reputation Points: 10
Solved Threads: 3
Yes, I've been teaching myself for awhile. I'm fine with most aspects, its just pointers have always kicked my ass in one way or another, like the compiler will expect me to put something in that pointing to the pointer of something (**) and I'll google, not figure it out, then just post here. This is due to the fact that you guys rawk!!! thx much skata :)
Manutebecker
Junior Poster in Training
51 posts since May 2008
Reputation Points: 10
Solved Threads: 3