I have a class responsible for handling the physics side of collisions. When the collision detector spots a collision, it notifies both entities in the collision to take care of gameplay. It also notifies the
PhysicsGenerator to take car of the physics of the collision.
I don't know if it's possible to avoid type checking in the
handleCollision() method of
PhysicsGenerator. What I wanted to do is apply a force on both entities in the collision to push them backwards. But I can only do this if they are
MovingEntities. What if one of them is a
StaticEntity? In this case it should be treated differently. I don't know how I can do that without using
instanceof quite a lot.
How is this usually handled?