- Home
·
- Games
·
- Been looking 4 a while 4 a code that you can give it 4 guardenats (X1,X2,Y1,Y2) and it returns a an
Been looking 4 a while 4 a code that you can give it 4 guardenats (X1,X2,Y1,Y2) and it returns a an
Been looking 4 a while 4 a code that you can give it 4 guardenats (X1,X2,Y1,Y2) and it returns a angle in degrees, however the codes and
API Declarations
'you can get X1,X2,Y1,Y2 from a line of some thing line1.x1 etc..
'if you place a line line1 on the screen 240pixels accross and 240pixels up the line should be X1 = 0:X2=240:Y1=240:Y2 = 0 and the program would return get_deg = 45 degrees. useful for game (i'm using it for gravity wormhole)
Rate Been looking 4 a while 4 a code that you can give it 4 guardenats (X1,X2,Y1,Y2) and it returns a an
(2(2 Vote))
Function get_deg(X1, X2, Y1, Y2)
radian = 3.1415927 / 180
If Y2 - Y1 = 0 Then Angle = 91 Else If X2 - X1 = 0 Then Angle = 1 Else Angle = Atn((Y2 - Y1) / (X2 - X1))
Angle = Angle / radian
If Angle < 0 Then
Angle = Angle + 360
End If
If Y2 >= Y1 Then 'line above point
If Angle <= 90 Then Angle = 360 - (90 - Angle) Else Angle = 90 - (360 - Angle)
Else
If Angle <= 90 Then Angle = Angle + 90 Else Angle = Angle - 90
End If
If Angle >= 180 Then Angle = Angle - 180 Else Angle = Angle + 180
get_deg = Angle
End Function
Been looking 4 a while 4 a code that you can give it 4 guardenats (X1,X2,Y1,Y2) and it returns a an Comments
No comments yet — be the first to post one!
Post a Comment