I followed this theory Here to implement a simple scrolling 2D terrain for my running game. I am used to dealing with collision via a tile system but am looking for a good theory on how to perform terrain collision (keeping the player on-top the land) with a midpoint displacement 2D terrain
I am not worried about the physics aspect but how to determine if a character intersects an array of points generated by the theory above. Example if I have an array of points
Points[]
these points are used to draw lines to make a terrain. Now in my mind I would first find the player center. Take the center X and see which two points it is between. So if X is 4.6 lets say it is between points that lay on X=3 and X=6.
Player X = 4.6
Point1 X = 3, Y = 3
Point2 X = 6, Y = 5
So now knowing this I somehow need to calculate what Y would be giving that X = 4.6. And once I have Y ensure that the Player Y > CalculatedY. If it is not push the player up to what Y the player should be.
So I guess what I a saying is
X = 3, Y = 3
X = 6, Y = 5
X = 4.6, Solve for Y