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
    maxRadious = 25
    maxDistance = WIDTH/2
    total = 200
    circles = {}

    for i=0,total do
        table.insert(circles,i,{math.random(maxRadious,WIDTH), math.random(maxRadious,HEIGHT),0.1 + math.cos(math.random(0,8))*minSpeed, 0.1 + math.cos(math.random(0,8))*minSpeed, math.random(200,255), math.random(100,200), math.random(0,100), math.random(100,200), math.random(5,maxRadious)})
    end
end

function draw()
    background(203, 65, 31, 255)
    blendMode(ADDITIVE)
    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)
        
        ellipseMode(RADIUS)
        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 :stuck_out_tongue: