Hey guys! So, here goes the code at first.
char.h
1 2 3 4 5 6 7 8 9 10 11 12
|
#ifndef CHAR_H
#define CHAR_H
struct Character
{
int hp;
int attk;
};
extern Character goon;
#endif
|
char.cpp
1 2 3 4 5
|
#include "char.h"
//declaring goon again
//because of extern
Character goon = {50 , 25};
|
Now here is the problem. In main.cpp, I want the player to be able to face multiple
goon
enemies, without declaring multiple enemies like
Character goon , goon1 , goon2 , goonN
.
Moreover, the player is going to face a random number of enemies. Even an array thingy can't work, because then I would have to hardcode all encounters as
int goonEncounter ()
indifinite times. And I don't want to do that. I have heard that
class
have their own functions as a part, but I'm still not much into them. Constructors and pointers are like hell. What I want, apparently, is to automate the encounter process, so that
Character goon;
can exist as indifinite separate independent instances. Say the PRNG gives out 10, so I want that there be 10
Character goon;
as declared above, but with independent hp (attk is same to each goon), such that they are able to provide independent encounters, having me code
int goonEncounter ()
only once, and not a separate function for each. You got the picture right? I don't know, or can't brainstorm, how to do that all. It would be very nice if you guys could point me to the right direction. Please take a note again that I am still struggling at pointers, so providing advice that involves using them wouldn't help me much. But ,if what I wish can't be achieved in my current skillset, I'm willing to invest time in learning about pointers and classes. Thanks in advance!