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