| 12-15-2006, 03:01 AM | #1 |
Apparently doing: JASS:Rect( x - radius, y - radius, x + radius, y + radius ) JASS:function GetRectFromCircleBJ takes location center,real radius returns rect local real centerX = GetLocationX(center) local real centerY = GetLocationY(center) return Rect(centerX - radius, centerY - radius, centerX + radius, centerY + radius) endfunction Edit: Unless ofcourse this function is used to determine a square, given a circle? Sorry for this, but in addition, if a function returns a location does it leak? JASS:function just_for_kicks takes nothing returns location local location m = Location( GetRandomReal( -120, 120 ), GetRandomReal( -120, 120 ) ) return m endfunction Edit: Wow, go figure, the second I resort to posting this on these queries on the forum the answers come to me instantly. If anybody wants to answer these for somebody else's use, go ahead, I already figured it out (I'm so dumb). |
| 12-15-2006, 06:23 AM | #2 |
First point: You can't make rects that are circles. Just do checks. dx^2 + dy^2 <= r^2, then it is in the circle. Second point: It doesn't leak an object, just has the potential to leak an object. You must set it to a variable in the function where you are using it, and then clean it up there. If you need to return an object, then of course you need to return an object. There is a handle index leak though. Just use: JASS:return Location(GetRandomReal(-120.,120.), GetRandomReal(-120.,120.)) |
| 12-15-2006, 10:01 AM | #3 |
Hopefully everybody who didn't know this can benefit from it. I got confused because I thought saying: return Location(...) leaked a location. However I soon after corrected myself and got it working. The other confusion with RectFromCircle was that I thought it took a rect (square) and made a circle, when infact it made a circle and created a square (rectangle, sorry). Nonetheless, thanks. |
