# _Angle(x,y) relevant to center of screen.

## Recommended Posts

```\$centerx=@DesktopWidth / 2
\$centery=@DesktopHeight / 2

\$CALx=0
\$CALy=0
While 1
Local \$pos = MouseGetPos()
If \$pos[0] > \$centerx Then
\$CALx=\$centerx-\$pos[0]
ElseIf \$pos[0] < \$centerx Then
\$CALx=\$centerx+\$pos[0]
EndIf
If \$pos[1] > \$centery Then
\$CALy=\$centery-\$pos[1]
ElseIf \$pos[1] < \$centery Then
\$CALy=\$centery+\$pos[1]
EndIf
ToolTip(_Angle(\$CALx,\$CALy ))
WEnd

Func _Angle(\$X, \$Y)

Local \$CX = \$centerx, \$CY = \$centery

If (\$CX = \$X) And (\$CY = \$Y) Then
Return SetError(1, 0, -1)
EndIf

Local \$Grad = (\$Y <= \$CY) * 180 - ATan((\$CX - \$X) / (\$CY - \$Y)) * 180 / 3.1415926535897932384626 + 90

EndIf
EndFunc   ;==>_Angle```

It sort of works but  doesn't.

can I get some help here?

##### Share on other sites

Currently I'm sick and my brain doesn't work well but you can try this:

Br,

UEZ

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

##### Share on other sites

I got this working.

```Func Angle(\$tX, \$tY, \$cX, \$cY)
\$mx = \$tX - \$cX
\$my = \$cY - \$tY
\$angle = ATan(\$my / \$mx) * \$180_div_pi
If \$mx < 0 Then
\$angle = 180 + \$angle
ElseIf \$mx >= 0 And \$my < 0 Then
\$angle = 360 + \$angle
EndIf
Return Int(\$angle)
EndFunc```

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...