ID:155599
 
what I am tying to do is make a pixel run along the path of a circle in a 32x32 title
closest i got this crazy parabola

mob/verb/shoot()
var/obj/o = new/obj/dot
o.loc=usr.loc
o:pixel_x=-((4+4-(abs(Tim)))**2)+30
o:pixel_y=(Tim)+23
mob/verb/Up()
usr.Tim+=0.5

excess info
a change in the Tim var shifts the location of creation when a new pixel is created
the point i wanted the circle to begin at was at 32,14
for this Tim was orginal value was -9
Majorminor wrote:
> mob/verb/shoot()
> var/obj/o = new/obj/dot
> o.loc=usr.loc
> o:pixel_x=-((4+4-(abs(Tim)))**2)+30
> o:pixel_y=(Tim)+23
> mob/verb/Up()
> usr.Tim+=0.5
>


First off, don't use ":" like that, that's a terrible habit. Also, change usr to src.

You can do this:

mob/verb/Circle()
var/obj/o = new/obj/dot
o.loc = locate(x, y, z)//same as locate(src.x, src.y, src.z) src = mob = user that clicks the verb
var/radius = 32//The distance from the center of the circle
for(var/angle = 0 to 360 step 10)//step #, # = how fast you want it to move around the circle
o.pixel_x = cos(angle) * radius
o.pixel_y = sin(angle) * radius
sleep(1)

In response to Zaltron
thanks for the help Zaltron
The algorithm Zaltron provided, while generally effective, is somewhat limited. Here's an algorithm I suggest you use instead, as it may be more resource-efficient and allow for circles of bigger sizes. I assume you want a perfect circle, and don't want it to be filled in (in which case you'll have to use another algorithm).


// turf/t = the turf of origin, i.e. usr.loc
// radius = the distance from the point of origin to the circle's exterior, basically, the radius.

// returns : a list of turfs on the circle's line
proc/findring(turf/t, radius)
var/list/result = new
var/f = 1 - radius
var/ddF_x = 1
var/ddF_y = -2 * radius
var/x = 0
var/y = radius
result += locate(t.x, t.y + radius, t.z)
result += locate(t.x, t.y - radius, t.z)
result += locate(t.x + radius, t.y, t.z)
result += locate(t.x - radius, t.y, t.z)
while (x < y)
if (f >= 0)
y--
ddF_y += 2
f += ddF_y
x++
ddF_x += 2
f += ddF_x
result += locate(t.x + x, t.y + y, t.z)
result += locate(t.x - x, t.y + y, t.z)
result += locate(t.x + x, t.y - y, t.z)
result += locate(t.x - x, t.y - y, t.z)
result += locate(t.x + y, t.y + x, t.z)
result += locate(t.x - y, t.y + x, t.z)
result += locate(t.x + y, t.y - x, t.z)
result += locate(t.x - y, t.y - x, t.z)
return result