# Help with circles

The circles keep drifting up into the top right corner and I don’t know why. Can someone help

``````-- circles
displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)

function setup()
minSpeed = 0.01
maxDistance = WIDTH/2
total = 200
circles = {}

for i=0,total do
end
end

function draw()
background(203, 65, 31, 255)
for k,v in pairs(circles) do
fill(v[5],v[6],v[7],255)
v[8]=math.max(v[8]+math.cos(math.random(0,180)+v[7]+v[8])*2,100)

ellipse(v[1], v[2], v[9])

circles[k][1] = math.max(math.min(v[1]+v[3], WIDTH-v[9]),v[9])
circles[k][2] = math.max(math.min(v[2]+v[4], HEIGHT-v[9]),v[9])
end
end

function createCircle(x,y,r)
local circle = physics.body(CIRCLE, r)
-- enable smooth motion
circle.interpolate = true
circle.x = x
circle.y = y
return circle
end
function distance(dx,dy)
return 1.426776695*math.min(0.7071067812*(math.abs(dx)+math.abs(dy)), math.max (math.abs(dx), math.abs(dy)));
end

``````

@kirorp You’re constantly increasing the x,y values of the circles by small amounts. See the lines “circles[k][1]” and “circles[k][2]” . Also see the lines in table.insert where you’re doing math.cos() .

This is how good at math I am