Whenever I try to run my program it keeps giving me an overflow error and I dont know why. The problem is shown when i call this sub:
blueP.shootBall(blueS.x, blueS.y, blueP.ang, blueP.captured, ball.x, ball.y, ball.velx, ball.vely)
this is the sub
Public Sub shootBall(ByVal x, ByVal y, ByVal ang, ByRef caputred, ByRef xb, ByRef yb, ByRef velx, ByRef vely) 'x and y are blueS.x and y
xb = System.Math.Round(x + ((18 - System.Math.Sqrt((x + 12 - (xb + 6)) ^ 2 + (y + 12 - (yb + 6)) ^ 2)) * System.Math.Cos(ang)), 5) 'moves ball out of capture range
yb = System.Math.Round(y + ((18 - System.Math.Sqrt((x + 12 - (xb + 6)) ^ 2 - (y + 12 - (yb + 6)) ^ 2)) * System.Math.Sin(ang)), 5)
caputred = False
velx = 2 * System.Math.Cos(ang)
vely = 2 * System.Math.Sin(ang)
'Form1.Timer1.Stop()
'MsgBox(velx & " " & vely & " " & System.Math.Sqrt((x + 12 - (xb + 6)) ^ 2 + (y + 12 - (yb + 6)) ^ 2))
'Form1.Timer1.Start()
xb += velx
yb += vely
End Sub
all the numeric variables should be decimals