Beginner here- ellipse joining question

hello, im relatively new to codea and have a neat game in mind but haven’t found the videos or help to get me to it. My idea is pretty simple. Your a bubble (ellipse) and can move around eating other bubbles to grow in size. My question is, how would I code to be able to show my bubble eat or merge into another smaller bubble while growing in size, aswell as how could I slow the pace my bubble moves as it grows? thank you for any responses:) - Vaughan

Do a forum search for metaballs. It’s exactly the effect you’re describing. Someone made some great metaballs Codea code.

Looking into an agario clone? It’s pretty simple aside from the metaballs. If you want to make your bubble larger when you eat another bubble, you could try using tweens for a smooth animation. For the movement, you could try just dividing the speed by the size of your bubble. As for metaballs, you could look at this thread, which has a lot of metaball shaders in it. Keep in mind they’re pretty advanced and expensive, however, and if you’re looking for something simple you could just use basic ellipses.

not sure what you mean by an agario clone? the metaballs thread looks a bit out of my comfort zone for now…lol but I am looking into to tweens, this is all mostly new to me and if not to use metaballs what would be another version to use eclipses instead?

@VGA39 I’m not sure how you want to do everything, but here’s a way to use just ellipses. What I’m doing is, if the larger ellipse touches the center of the smaller ellipse, then it starts to eat the smaller ellipse. The smaller ellipse shrinks in size and the larger ellipse can’t move while eating the smaller ellipse. Once it eats the smaller ellipse, it will grow in size based on the shape of the smaller ellipse. Since I don’t know how you will create new ellipses, I just create another ellipse at a random x,y position with a random size. I also don’t know how you’ll move the larger ellipse, so I have it set up to move based on how you slide your finger anywhere on the screen. Just keep eating the smaller ellipses to see how it works. If this isn’t anything like you want, maybe someone else can use it for something.

displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)

function setup()
    x,y=WIDTH/2,HEIGHT/2
    w,h=50,80
    dx,dy=0,0
    x1,y1=300,700
    w1,h1=20,30
end

function draw()
    background(40, 40, 50)
    fill(255)
    ellipse(x+dx,y+dy,w,h)
    fill(255,0,0)
    if not eating then
        ellipse(x1,y1,w1,h1)
    else
        ellipse(sp.x,sp.y,sp.w2,sp.h2)
    end
end

function touched(t)
    -- move larger ellipse
    if t.state==MOVING then
        if not eating then     
            dx=dx+t.deltaX
            dy=dy+t.deltaY   
            -- check if eating
            if (x1-(x+dx))^2/(w/2)^2+(y1-(y+dy))^2/(h/2)^2 <= 1 then 
                tw()   
            end        
        end
    end
end

function done()
    -- create a random ellipse at random position
    eating=false
    w=w+w1/5
    h=h+h1/5
    w1=math.random(10,40)
    h1=math.random(10,40)
    x1=math.random(50,WIDTH-50)
    y1=math.random(50,HEIGHT-50)
end

function tw()
    -- move smaller ellipse to center of larger ellipse
    eating=true
    sp={x=x1,y=y1,w2=w1,h2=h1}
    tween(5,sp,{x=x+dx,y=y+dy,w2=0,h2=0},tween.easing.linear,done)
end