This is the part I currently need to work on for my own game..
What I've reasoned out so far is that I can have a CollisionBox on the GameObject which contains all the collision boundary information. Collisions are checked by GameObject.isColliding(other) - where the two CollisionBoxes compare whether they intersect.
if (gameObject.isColliding(other))
{
gameObject.doCollision(other);
}
then the GameObject has a doCollision method which is overridden for various GameObjects
public GameObject
{
CollisionBox collisionBox;
CollisionType collisionType;
public void doCollision(GameObject other)
{
switch(other.CollisionType)
{
case Inelastic: //etc
case Elastic: //etc
case Consumable: //(this one is for bullets, upgrades, pickups -
// things you collide with but the collision doesn't affect motion)
}
}
}
As you can maybe guess, CollisionType is an enum which is assigned to GameObject.
That was my initial plan anyway. Now I hope to take some inspiration from Collision detection and response in an Entity SystemCollision detection and response in an Entity System - though I'll still probably end up with some type of "collisionType enum" to broadly group a type of collision.