Here's the deal; some objects in my game have different manners for detecting collision than others. Right now everything's a bounding box, but for the next iteration of this game engine I need 3D. I might throw in bounding spheres later too, but anyway. Now, here's an idea of my current class hierarchy:
| |-->SpritePlatform |-->EnemyType1
| |-->3DVectorBasedPlatform |-->EnemyType2
| |-->Tilemap |-->etc.
Now some of these objects (like SpritePlatforms, some enemies and particles, and maybe the player) can and are represented by sprites using my 2D animation class, which carries the bounding box data with it. This 2D animation storage is currently built into the base class. Some of the objects I would like to represent using 3D polygons and rotatable bounding polys, which I can't do right now.
Here's a system I thought of: remove the animation system from BaseClass. In fact, remove all the graphics and collision handling code from all those objects! Mua ha ha ha ha ha! In its place, I would create (in this case) two classes for handling this stuff; one would be a C2DObject with the current sprites and boxes, and the other would be a C3DObject with 3D model and animation data, and whatever I decide is a good method for checking collision detection. Obviously, 2D objects can collide with 3D ones (this being a 2D game engine, that's easy ).
So now here's the wild idea; I would declare some of those classes above in this manner now:
class SpritePlatform: public Platform, public C2DObject
class VectorBasedPlatform: public Platform, public C3DObject
class EnemyType1: public GameEntity, public C2DObject
class EnemyType2: public GameEntity, public C3DObject
And now, when two objects get in each other's personal elbow space, the game can check the object type and call the correct collision detection code. In fact, I may have to check this since I've never done it, but I could probably just make some overloaded collision functions that take pointers to C2DObject's and C3DObject's, and then just call those functions with wild abandon since the right function would get called by the object's type! I'm giddy just thinking of it!
Any thoughts? Just brainstorming here, but it sounds pretty solid to me ...
EDIT: C'mon, relevant posts >_< I'm trying to keep this forum alive, dammit ... we can go OT around post 50, I promise ...