I have the Lerp function working but I was wondering if anyone could tell me how I can get more points between the two initial points so I can draw an actual line and not just dots. Right now it is always 10 points no matter how far away the points are from each other. I know why this is but what I am looking for is how to add more points and take away points depending on how far the two initial points are from each other. So the closer they are the less points you would need to draw a line and the further the more points you would need. Any help is appreciated
SetVirtualResolution(480,480)
Global dot1
Global dot2
Global line
myimage = LoadImage("1.png")
dot1 = CreateSprite(myimage)
SetSpriteSize(dot1,4,4)
dot2 = CloneSprite(dot1)
count1 = 0
count2 = 0
space = 32
esc = 27
Dim x_arr#[9]
Dim y_arr#[9]
posx1# = 20.0
posy1# = 20.0
posx2# = 80.0
posy2# = 80.0
For i# = 0.0 To 1.0 Step 0.1
x_arr#[count1] = Lerp(posx1#,posx2#,i#)
y_arr#[count1] = Lerp(posy1#,posy2#,i#)
Inc count1
Next i#
SetSpritePosition(dot1,posx1#,posy1#)
SetSpritePosition(dot2,posx2#,posy2#)
For i# = 0.0 To 1.0 Step 0.1
line = CloneSprite(dot2)
SetSpriteColor(line,0,100,255,255)
SetSpritePosition(line,x_arr#[count2],y_arr#[count2])
Inc count2
Next i#
Do
If GetRawKeyPressed(space) = 1
DeleteSprites()
posx1# = Random(20.0,400.0)
posy1# = Random(20.0,400.0)
posx2# = Random(80.0,400.0)
posy2# = Random(80.0,400.0)
SetSpriteSize(dot1,4,4)
dot2 = CloneSprite(dot1)
count1 = 0
count2 = 0
For i# = 0.0 To 1.0 Step 0.1
x_arr#[count1] = Lerp(posx1#,posx2#,i#)
y_arr#[count1] = Lerp(posy1#,posy2#,i#)
Inc count1
Next i#
SetSpritePosition(dot1,posx1#,posy1#)
SetSpritePosition(dot2,posx2#,posy2#)
For i# = 0.0 To 1.0 Step 0.1
line = CloneSprite(dot2)
SetSpriteColor(line,0,100,255,255)
SetSpritePosition(line,x_arr#[count2],y_arr#[count2])
Inc count2
Next i#
EndIf
Print("Press Space")
Sync()
Loop
Function Lerp(p1#,p2#,i#)
result# = p1#*(1-i#)+p2#*i#
EndFunction result#
Function DeleteSprites()
For i = 10002 To line
DeleteSprite(i)
Next i
EndFunction