//Returns a list of turfs in the border of a circle
/proc/returnCircle(var/turf/origin, var/radius)
var/list/circle = list()
for(var/i = 0, i <= radius, i++)
var/dx = i
var/dy = round(sqrt((radius**2) - (dx**2)), 1)
var/y = origin.y + dy
var/x = origin.x + dx
var/turf/P = locate(y, x, origin.z)
circle += P
y = origin.y - dy //repeat the process again to account for negative values that sqrt() doesnt return
x = origin.x - dx
P = locate(y, x, origin.z)
circle += P
return circle
Problem description:
So I am trying to code a thing the returns a circle with a given radius and origin. Posted is what I have so far, but it only returns the turfs on the perimeter. Short of having it run a check on every single turf in a square with side length of the radius, how would i return the contents of the circle?
Do you want the objects, or do you just want all the turfs? If you want the objects, you'll want to use obounds() instead of block().
Using the square distance also has an advantage of not having to check each tile twice.