ID:142450
 
OK so my goal is to make a circular listing of tiles around a specified atom. Im getting really confused at this point, could someone help?


Code:
proc/Square(var/atom/A) //this proc draws a square up and to the right of the player
var/list/square = new
var/max_dist = round((A.radius+31)/32) + 1 // atoms with bigger radius need to include more tiles (radius is in pixels)
var/X
var/Y
for(X = A.x+1, X <= A.x+max_dist, X++)
for(Y = A.y+1, Y <= A.y+max_dist, Y++)
square += locate(X,Y,1) // loop adding the tiles to the list
Distance(A, square, A.radius + 32) // do i need to say list/square?
// pretty sure this works so far


proc/Distance(var/atom/A, var/list/L, radius)
for(var/turf/T in L) // for only the turf contained on the list // do i need to specify that these are turfs?
var/list/circle = new
var/closest_x = ((T.x - A.x) * 32) - A.tile_x + 1 // the closest pixel 1,1 is checked
var/closest_y = ((T.y - A.y) * 32) - A.tile_y + 1
if(closest_x^2 + closest_y^2 < radius^2)
circle += T // adds the tile to the new list, which should be the upper right corner of a circle


client/verb/circle_test()
Square(usr/mob)

// i need a better verb for testing, i got no output. maybe making tiles inside the range luminous?



It compiles but doesnt do what i need. I wasnt going to ask for help on it so that i could present it when its finished but i dont see that happening without help. When im done its gonna rock!
1. When working with the client type, you don't need to put usr.mob, just put mob.

2. http://www.byond.com/docs/ref/info.html#/proc/block
In response to Darkmag1c1an11
oh thats handy as heck, thanks!

guess ill modify my code a bit
^ is not the exponentiation operator, it's the bitwise XOR operator. ** is for exponentiation.

You should just be using regular multiplication, though, because exponentiation carries more overhead.
In response to Garthor
what do you mean by it carrying more overhead?

will use multiplication tho