If the domain and range are the rationals, the answer is no. There is no rational square root of ½. The path is continuous in this metric space, but the curve does not attain the value of 0, because the rationals are not complete. If the metric space is complete, every intermediate value is attained. We'll prove this for y = 0.
Let S be the set of points with y < 0. These points have x coordinates that are bounded by 1. Let u be the least upper bound of this set. We know that u exists, because the reals are complete. Let v = f(u). If v is positive then values of x near u have f(x) positive, and u is not the least upper bound. If v is negative then values of x beyond u still have f(x) negative, and u is not a valid upper bound. Therefore v = 0. Every intermediate value has some x with f(x) equal to that value.
This theorem remains valid if the domain is n dimensional space, or even generalized euclidean space. If the bottom of the hill is at sea level, and the top of the hill is 1,000 meters high, there is some point on the hill with elevation 374 meters. Draw a path, any path, from bottom to top and apply the previous theorem.