using grid for optimized ball collision detection