[edit]
Get a pen and some paper, and draw everything i say
[/edit]
Lets say that a slope has an interval along the x axis [a,b], such that a < b.
Because the slop is only 45 degrees, this simplifies things.
The slope begins at a position (a, some y value) and ends at a position (b, some y value)
Lets call the y value for the beginning position u.
The end points y value will then of course be u, plus the distance from a to b, ie u + (b - a) = u + b - a
Lets call this y value, v.
So, the slop has interval [a,b] along the x axis, [u,v] along the y axis, and goes straight from the point (a,u) to the point (b,v), where a<b and u<v (and of course v - u = b - a )
The y value on that slope for any given x value is defined as being as distant from u as the x value is from a.
This can be thought of as making (a,u) the origin of a new coordinate system.
On that new coordinate system, lets call it XY, and not xy (the screens normal coord system), Y is equal to X on the line/slanted barrier.
If you have an X value, and want to obtain the Y value on that line, you know the it is the same as the X value.
However, we are dealing with xy, and not XY coordinate system.
To make things easy/abstract, we convert from xy to XY, (ie change the x value into an X value) and obtain the Y value through X=Y, then convert it back into a y value.
To convert from XY to xy? Well XY is defined as having an origin such that X=Y=0, at the position (a,u) on xy.
So that means that at x = a, X = 0, and at y = u, Y = 0.
So, at x = 0, X = -a, and at y = 0, Y = -u
X is a translation of a from x, and Y is a translation of u from y
ie:
To convert from an x value to an X value, subtract a, and conversely add a to an X value to obtain an x value.
To convert from a y value to a Y value, subtract u, and conversely add u to a Y value to obtain a y value.
(It helps to draw two axes, one at 0,0 and one at a,u, and convert a point or two on paper)
Are you scribbling lines all over some sheet of paper?
So, to evaluate the y value from an x value within the interval of the slanted barrier (which can be checked easily as standard: player.x >= a and player.x <= b ), you :
subtract a from the x value to get the X translation of it
Get the Y value, witch is the X value..so...do nothing really!
add u to this Y value to get the y translation of it.
And now you have the y value at the ground level of that sloped surface for any x point along it (and of course obtaining the x value from the y value is very easy).
So, you can allow the player to move, calculate the slopes y value, and say "' if player.y is less than slope.y, then player.y := slope.y '" , and the player will be able to move horizontally and never be beneath the slope, as long as the y value when approaching the slope in the interval [a-xspeed, a] is always greater than u, and the equivelant on the other side with b,v. + xspeed etc.
You could then reduce xspeed or multiply it by a factor less than 1.0, when in the closed region [a,b] of the slope if neither jumping nor falling; This should be done so that the diagonal movement is not too fast.
If you wanted levels where some slopes are beneath others however, youll have to make a vertical closed interval which player must be in, in order for that slope to be taken care of. ie define a y1,y2 (tired of a,b ..c,d would just confuse things, its time for some proper notation) such that the slope is only considered at all "' if player.y >= y1 and player.y <= y1 '" This boundary must be wider on the top and bottom, from u and v, by at least more than the players expected maximum vertical movement. Doing this will allow some slopes to lie beneath others, however, an aidditional upsid down slope object will be needed to stop jumping up from beneath the slope (although that can be used often in sidescrollers)
This, however, is for a slop going downwards as x increases, not upwards.
It wouldnt be any difficulty to convert the ideas, and is better anyway as understanding will be needed to implement this, and if you have to work out some of your own things on paper first, it'll help.
...I know <0 about goodnights walking engine however ..