Added a basic collision detection algorithm.