Hi there currently creating a small game with graphics using Allegro 5.
Though I am having some issues on which is the most proper way to create several monsters without having to create them all individually.
Here's what I have now.
Monsters.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#ifndef MONSTER_H_
#define MONSTER_H_
class Monster
{
private:
int health_; //Current health
protected:
Monster();
public:
virtual ~Monster();
virtualvoid attack();
};
#endif
Say I want a monster called Blob and a monster called Goat, where would I go from here if I would like to add monsters that inherit from this monster class, the proper way?
The proper way is to have each species be a subclass of Monster.
The proper proper way is use C++ only for resource management and various other low level functions, and write the game logic itself in a different language. So, instead of classes like 'Monster' and 'GelatinousCube', you'd have 'Sprite' and 'AudioDevice'.
Lua is a common option for this second language.
Hi, not really what I was looking for but I guess it could help in the future.
Keep in mind I am still new at programming and just looking for an answer for my question.
Which is a proper way to create a sub monster class, say a blob or a dragon, that inherits from the monster class.
I reckon all monsters have Hitpoints, Strength, Defense, Drops, Attacks etc.. I heard a good way of organizing this is using inheritance.
Can you give me an example? :)