If i have a Rocket that fires a bullet at an enemy ship, where should the collision be detected. Should the bullet detect the enemy ship or should the enemy ship detect the bullet ?. Or does it not matter.
It matters not which detects which; however, I prefer to have the object that is being hit (the ship) detect the object that hits it (the bullet). My reasoning is this: a local field (or variable) could contain the object detected (the bullet)and be used to remove it from the world; and being it (the bullet) will be removed no matter what happens to the object that is hit (the ship), there will be no possibility of NullPointerExceptions after removing it (the bullet). Also, this is the point when damage must be assessed to the object being hit (the ship); which can be done right there; instead of calling a public method in this class (Ship) from the other class (Bullet) to process it.