function setup()
x1,y1=0,0
x2,y2=0,0
end
function draw()
background(40, 40, 50)
stroke(255)
strokeWidth(2)
if x1+y1>0 and x2+y2>0 then
line(x1,y1,x2,y2)
end
fill(255)
if x1+y1>0 then
ellipse(x1,y1,10)
end
if x2+y2>0 then
ellipse(x2,y2,10)
end
end
function touched(t)
if t.state==BEGAN then
if x1+y1==0 then
x1=t.x
y1=t.y
elseif x2+y2==0 then
x2=t.x
y2=t.y
else
x1=t.x
y1=t.y
x2,y2=0,0
end
end
end
@Apselon Here's a stripped down version that uses Boolean variables.
function setup()
first=true
end
function draw()
background(40, 40, 50)
stroke(255)
strokeWidth(2)
if show then
line(x1,y1,x2,y2)
end
end
function touched(t)
if t.state==BEGAN then
if first then
x1,y1=t.x,t.y
first,show=false,false
else
x2,y2=t.x,t.y
first,show=true,true
end
end
end
Comments
@Apselon Try this.
@dave1707
Thank you
@Apselon Here's a stripped down version that uses Boolean variables.