Jump to content
  • Advertisement
Sign in to follow this  

Creating Enemies

This topic is 1405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello All,

Another design question here. I am creating enemies in my JRPG and have come to another sticking point.
Namely, do you create a single "Enemy" class and then instantiate objects of that type, then load the respective properties from say a flat file or database like "Bestiary";
enum EnemyType{
Orc = 1;
Goblin = 2;
Skeleton = 3;
DireWolf = 4;
Zombie = 5
Enemy Orc = new Enemy(EnemyType.Orc);
Enemy Zombie = new Zombie(iEnemyType.Zombie);
Or do you create a different sub-class for each type of enemy, and then hard code the properties for that class?
Or is it just a case of personal preference? 
I hope that all makes sense and thanks for the help.

Share this post

Link to post
Share on other sites

I normally write a base class with all common properties there and than a subclass for every enemy which allows me to easily modify their behaviour independently.

Share this post

Link to post
Share on other sites

This is a typical problem where composition and data oriented design should be preferred. Reason is that inheritance yields in more maintenance problems due to needlessly deep hierarchies, and design work would be burdening the programmer.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!