I don’t remember if something like this was posted before, but this was something I just threw together. The object is to change all the circles from red to green. When you tap a circle, it will flip its color (red to green or green to red) along with each circle on both sides of it. It starts at 5 circles, but will increase by 2 circles each time you change them to all green. If someone want to make this more interesting, go for it.
supportedOrientations(LANDSCAPE_ANY)
function setup()
nbr=5
setup2()
end
function setup2()
prnt=true
sol={}
win=false
pos=0
moves=0
tab={}
for z=1,nbr do
a=360/nbr*z
x=math.sin(math.rad(a))*350+WIDTH/2
y=math.cos(math.rad(a))*350+HEIGHT/2
table.insert(tab,vec3(x,y,0))
end
end
function draw()
background(227, 181, 107, 255)
if pos>0 then
swap(pos-1)
swap(pos+1)
swap(pos)
pos=0
end
for a,b in pairs(tab) do
fill(255,0,0)
if b.z==1 then
fill(0,255,0)
end
ellipse(b.x,b.y,50)
fill(255)
text(a,b.x,b.y)
end
fill(255)
text(#tab.." circles",WIDTH/2,HEIGHT/2+50)
text("Moves = "..moves,WIDTH/2,HEIGHT/2)
check()
if win then
text("Change complete.",WIDTH/2,HEIGHT/2-50)
text("Tap screen for next round.",WIDTH/2,HEIGHT/2-100)
if prnt then
prnt=false
output.clear()
print(table.concat(sol," "))
end
end
fill(0, 0, 255, 255)
end
function check()
win=true
for z=1,#tab do
if tab[z].z==0 then
win=false
end
end
end
function swap(p)
if p<1 then
p=#tab
elseif p>#tab then
p=1
end
if tab[p].z==1 then
tab[p].z=0
else
tab[p].z=1
end
end
function touched(t)
if t.state==BEGAN then
if win then
nbr=nbr+2
setup2()
output.clear()
return
end
pos=0
for z=1,#tab do
if t.x>tab[z].x-25 and t.x<tab[z].x+25 and
t.y>tab[z].y-25 and t.y<tab[z].y+25 then
pos=z
moves=moves+1
table.insert(sol,pos)
return
end
end
end
end