
-----------------------------------
RedRogueXIII
Wed Aug 30, 2006 4:29 pm

Why does the line equation hate me so?
-----------------------------------
Here is my test platform code for a 2d sidescroller, handling slopes and such,  I've gotten the main char ( a red ball ) to land on the platform then ascend a steep slope without weird bouncing, but on a slightly inverted 30* and less it gives me this weird bouncing. on straight surfaces it works fine. 

View.Set ("graphics:max,max, offscreenonly")
var x1, y1, x2, y2, meX, meY, distance : int
var m, b : real
var tX, tY : int
var controls : array char of boolean
% The line works fine on a straight or steep slope but screws up on a small slope
x1 := 200
y1 := 300
x2 := 500
y2 := 400

meX := 300
meY := 400
fcn wallDETECTION (x1_, y1_, x2_, y2_, charX_, charY_ : int, m_, b_ : real) : boolean
    var x, y, ratio : real
    var angle : int
    for i : x1_ .. x2_
        x := i
        y := (m_ * x) + b_
        drawdot (round (x), round (y), black)
        /*if (charX_ - round (x)) not= 0 then
         ratio := (charY_ - round (y)) / (charX_ - round (x))
         else
         ratio := (charY_ - round (y)) / 0.001
         end if
         angle := round (arctand (abs (ratio)))
         if (charX_ - round (x)) < 0 then
         angle := 180 - angle
         end if
         if (charY_ - round (y)) < 0 then
         angle := 360 - angle
         end if
         locate (1, 1)
         put angle ..*/
        if Math.Distance (x, y, charX_, charY_) = 0 and angle 