• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED animation curves

K

KekkoKamen

Guest
Hi,

I try to draw a curve using animation curves. What is weird, is that the curve is drawn perfectly up until the last two points, were it draws a straight line between the points instead of a curve.
Draw event:
GML:
var cha = animcurve_get_channel(cu, 0);
seg=612
segNum=room_width/seg

for (i=0; i<=seg;i++)
{
    p[i]=animcurve_channel_evaluate(cha,i/seg)
}
draw_set_color(c_blue)

for(i=0; i<seg; i++)
{ 
    x1=i*segNum
    y1=y-p[i];
    x2= (i+1)*segNum
    y2=y-p[i+1]

    draw_line(x1,y1,x2,y2) 
}
Here the curve, and the drawn curve on screen. I tried many things, I don't understand where my code is failing, because albeit the last two points, the curve draws perfectly. I tried many things, changing the aspect ratio, of the drawing. Adding points, subtracting points, the last portion is always a straight line.


curve.png
 
Last edited by a moderator:
K

KekkoKamen

Guest
Oh, and just to be clear, I'm not talking about the aspect ratio of the curve, I know it's "flatter", it doesn't matter. I'm talking about the straight section at the end of the curve.
 
K

KekkoKamen

Guest
Oh... Thanks for that! It felt a lot like a bug, but I wasn't confident enough in my coding abilities to admit it was. Well, that's a relief!
 
Top