What design pattern should I use for specific multiple inheritance?

Let's say I have an interface called Squid.

And we have a bunch of different types of squids:

Here's everything a squid can be:


How would I go about create an instance of a squid? Should I go about creating 4 classes BasicAquaticSquid, BasicLandSquid, AdvancedAquaticSquid, AdvancedLandSquid like this:

I think that's called the Abstract Factory method? It seems very tedious though. Any better way of doing so?


You are viewing a single comment. View All

@DynamicSquid I'm not sure if this is a good way of setting it up, although, I am not a game developer either. (This is a game you're attempting to program, right?)

Now, I have no clue how your game is going to work nor do I have many details, but if the squids are capable of battling each other, ideally, you would want a generic setup that would allow you to pit any two squids or players against each other, at runtime, without compiling a separate code template for every single possible combination of creature that could meet.

Let's say the core of the game revolves around pitting squids against each other (wait this sounds like Pokemon or something, eww), you have a function called battle.
It takes two formal parameters, each being the squid to take a side in the battle.

How would you set it up, if each squid has different methods? Duck typing isn't safe. And compiling something like battle<Squid1, Squid2>(Squid1 squid1, Squid2 squid2); for every possibility isn't fun either.

Also, in every game that I've played, to date, every different player could all do similar things at a high-level, they just have different animations.

Think of a shooting game, each firearm deals damage, and has velocity, yet they have different animations, sounds, trajectories, and numbers associated with their capabilities.

Personally, I might do something generic, like .move, .primaryAttack, .secondaryAttack, .canSwim, and give them all different implementations, but I'm not sure if it's the best way to do this, or if anyone else would agree with a structure like this.