3 ms·
This is something I've struggled with in the past as well. I have a player, NPCs, enemies, and wild animals. Should they have any class hierarchy at all? If
by SkyBelow 5y ago
This is something I've struggled with in the past as well.
I have a player, NPCs, enemies, and wild animals. Should they have any class hierarchy at all? If my code matches the game world, what happens when I was to add golems and let mages turn castle's into entities that act just like an NPC would? Should my class design be so tightly coupled with the elements of my world? I don't think so but what alternative works best?
- markus_zhang 5y agoCan you create a base class for all living things and derive from there? The base class owns a bunch of common components such as HP, Animation, Sound, etc, and each subclass has components that are specific for itself (for example, you cannot "Use" a player, but should be able to "Use" a wild animal, so here goes a component for that action).