I'm working on an RPG game for my coursework project. Everything is going fine but I've reached a stage where I do think that my project's code is not the most efficient.
Here I have a constructor of my class AbstractMob
public AbstractMob (String name, int hp, int attack, int defense, int magicAttack,
int magicDefense, int expBound, int goldBound, String folder, String idleAtlas, String attackAtlas) {
abilities = new ArrayList<>();
//setting variables
this.attack = attack; //and so on
idleAnimation = new Animation<>(
0.070f, new TextureAtlas(Gdx.files.internal(
"sprites\\mobs\\" + folder)).findRegions(idleAtlas),
Animation.PlayMode.LOOP);
attackAnimation = new Animation<>(
0.070f, new TextureAtlas(Gdx.files.internal(
"sprites\\mobs\\"+ folder)).findRegions(attackAtlas),
Animation.PlayMode.LOOP);
}
And here is an example of a class that inherits AbstractMob
public class FireElemental extends AbstractMob {
public FireElemental() {
super("Fire Elemental",
400,
12,
10,
18,
15,
50,
20,
"fireElemental\\fire.atlas",
"firesprite",
"firesprite"
);
//from AbstrctMob, declares any abilities the mob has
abilities.add(new Fire()); //same design pattern as these mob creations,
//I have a separate class for Abilities, and subclasses such as Fire
//that inherit from Abilities
setAbilities(abilities);
}
}
Now, my question is - does it make sense to create a multitude of separate classes (i.e make more classes like FireElemental
for different mobs) for each entity (whether that be abilities or mobs) for this game? How about utilising files/scripts to load them?
Thank you so much!