added collision detection code for obstacles [NOT WORKING YET]