Collision detection trouble

Having some difficulty with collision detection… Not sure if it’s because how I set everything els up or what
Here is my code so far w/o collision detection added in… Tips?

function setup() 
    B={}
    score=0
    PipeFrequency=.5
    timer=0
    gap=200
    LaunchPipe()
    position=vec2(WIDTH/2,HEIGHT/4)
    ballr=50
    bally=HEIGHT/2
end

function LaunchPipe()
    b={}
    b.x=0
    b.y=0
    b.w=math.random(75,WIDTH-gap-75)
    b.h=50
    b.s=5
    b.c=color(35, 197, 85, 255)
    b.x2=b.w+gap
    b.w2=WIDTH
    table.insert(B,b)
end

function draw()
    background(75, 184, 196, 255)
    pushStyle()
    timer=timer+DeltaTime
    if timer>1/PipeFrequency then 
        LaunchPipe()
        timer=0
    end
    for i,b in pairs(B) do 
        b.y=b.y+b.s
        if b.y<-b.w then
            table.remove(B,i) 
        end
        fill(b.c)
        rect(b.x,b.y,b.w,b.h)
        rect(b.x2,b.y,b.w2,b.h)
        ellipse(position.x,bally,ballr)
        end
        moveVec = vec2(Gravity.x, HEIGHT/2) + vec2( 0, 0)
       
         position = position + moveVec * 20
end

What exactly is your question?

Try reading some of the stuff on the wiki, almost everything involves collisions

@ignatz, his/her trouble is that the ball doesn’t collide with things and go trough instead diying

@Mark.T Are you having trouble with actual collision code, or are you having trouble with where to start with collision detection. There’s 2 ways to do collision detection. One is using the physics engine, the other is by writing your own code to see if the x,y positions of objects are within a certain distance of each other. You don’t say which way you’re trying.

@TokOut - his problem is not that his ball isn’t colliding - that’s because he hasn’t put collision code in yet!

His problem is that he doesn’t know how to do collisions - and there is a lot of sample code about collisions, as well as tutorials.

I am simply saying - before you ask on the forum, try looking in the wiki, searching the forum for past answers, etc. You could use that advice, too.

Ok, collision will be my next lua-subject to learn