Hi,
for example like
"zombie.h":
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
class zombie {
int attack ;
int healthbegin ;
int health;
int bowdefense;
int defense;
int magdefense;
// Position
public:
int x;
int y;
// constructor
void zombie(int at, int he, int he2, int bowd, int def, int magd); // body has to follow in "zombie.cpp"
// whole lot of methods, like "attack" or sth., and "move", for example .... all these methods have to be
// equiped with a "body" like the constructor .... better in "zombie.cpp"
void move(int x, int y); // (x, y) to define new position ....
void attack(PLAYER victim); // PLAYER would be another class, i.e. "victim" an object of class "PLAYER"
void ch_health(int h); //..........
void ch_attack(int at); // ..........
}
|
The "constructor" has to fill the fields like "attack" or whatever, so it will be a function consisting mainly of assignments and stuff like that.
The other methods should do what they are called like ...
methods and the fine difference to functions is the main issue in classes and objects, i think.
Your example only uses fields.
Differences arise, because you usually use the fields of an object like the fields of a struct, which means you won't have to declare so many names like "fmattack".
Declare a class "footman" with field "attack" instead ... simillar to "zombie"-class, as above.
In your "main"-fcn, you can then declare as many footmen or zombies as you please... using f.ex.
footman f1(... all your attributes ...);
Is that any clearer to you now ?
When you have understood that, you should read about "inheritance"... that'll please you, i guess when i look at your example.
You should by the way study a tutorial about that stuff, also because i will have made a lot of syntax errors, as usual.
Greets so far