10-04-2024, 10:57 PM
(10-04-2024, 10:04 PM)NakedApe Wrote: Also Terry I was checking out your library and noticed a Vec2Deg function that was longer than the one I use. Is this simpler version as useful?Yes, yours and Steve's routines are much better. Thank you for pointing that out and sharing the code.
Code: (Select All)Dim As Single Vx, Vy, angle
start:
Cls
Print "Type in vectors, Vx, Vy"
Input Vx: Input Vy
angle = Vec2Deg(Vx, Vy)
Print: Print "The answer is "; Using "###.###"; angle;: Print " degrees."
If Vx = 0 Or Vy = 0 Then System
Sleep
GoTo start:
Function Vec2Deg (Vx As Single, Vy As Single) '
' ** Turns vector pairs into degrees **
Dim As Double radian
Dim As Single degrees
radian = _Atan2(Vx, Vy) '
degrees = _R2D(radian) '
If degrees < 0 Then degrees = 360 + degrees '
Vec2Deg = degrees '
End Function
That goes for everyone, if you notice that any of my libraries can be enhanced/improved upon by all means let me know. Many of the small libraries I post with code here make up the larger game library I'm working on. The better the routines the better the library will be.