can anyone help me scale a quad to the same length as the line I am drawing below ? The lines endpoint is at the mouse x,y pos, I have no idea how to do this.
Strict
graphics 800,600
Function DrawScaledQuad(x1:Int,y1:Int,x2:Int,y2)
Local dx = x2-x1
Local dy = y2-y1
Local angle:Float
Local llen:Float = Sqr((x1 - x2) ^ 2 + (y1 - y2) ^ 2)
If Sgn(dy) > 0 Then angle = ATan2(dy,dx)
If Sgn(dy) < 0 Then angle = ATan2(dy,dx) '+ Pi
DrawLine x1,y1,x2,y2
SetScale llen,1
SetRotation angle
DrawRect x1,y1,3,3
SetScale 1,1
SetRotation 0
End Function
While not KeyDown(KEY_ESCAPE)
DrawScaledQuad(300,300,MouseX(),MouseY())
Flip
Cls
Wend
|