Here is a simple program to check your eye/hand coordination. The object is to tap the green circle before it disappears. Each time you tap the circle, the size and time to tap the next one will be reduced by 1. The 10 high scores will be kept. There is an instruction screen when the program starts.
-- popup
supportedOrientations(PORTRAIT)
displayMode(FULLSCREEN)
function setup()
--clearLocalData() -- uncomment to clear scores, then comment back.
fontSize(40)
init()
intro=true
highScore=false
start=false
end
function init()
w2=WIDTH/2
h2=HEIGHT/2
mainLoop=0
showLimit=100
limit=101
total=0
end
function draw()
background(40, 40, 50)
if intro then
help()
return
end
if highScore then
showHighScore()
end
if start then
if mainLoop==0 then
limit=limit-1
xc=math.random(limit,WIDTH-limit)
yc=math.random(limit,HEIGHT-limit)
radius=limit
showLimit=limit
mainLoop=100
else
mainLoop=mainLoop-1
if showLimit<=1 then
if xc~=-100 then
highScore=true
start=false
end
else
showLimit=showLimit-1
stroke(0,255,0)
strokeWidth(2)
noFill()
ellipse(xc,yc,limit*2,limit*2)
fill(0,255,0)
strokeWidth(0)
ellipse(xc,yc,showLimit*2,showLimit*2)
end
end
end
fill(255)
str=string.format("Circle size = %d",limit)
text(str,WIDTH/2,980)
str=string.format("Score = %d",total)
text(str,WIDTH/2,900)
end
function help()
fill(255,0,0)
local h2=900
text("Instructions",w2,h2+50)
fill(0,0,255)
text("Tap the green circle before",w2,h2-50)
text("it disappears.",w2,h2-100)
text("Each time you tap the circle,",w2,h2-150)
text("the size will be reduced by 1",w2,h2-200)
text("and the amount of time that you",w2,h2-250)
text("have to tap the next one is also",w2,h2-300)
text("reduced by 1.",w2,h2-350)
text("If you don't tap the green circle",w2,h2-400)
text("fast enough, the program will end",w2,h2-450)
text("and show you the 10 highest scores.",w2,h2-500)
text("Your score will be added to the list",w2,h2-550)
text("if it is high enough.",w2,h2-600)
text("A new circle will appear",w2,h2-650)
text("about every 1.5 seconds.",w2,h2-700)
fill(0,255,0)
text("Tap the screen to continue",w2,h2-800)
end
function touched(t)
if t.state==BEGAN then
if intro then
intro=false
highScore=true
return
end
if highScore then
if t.tapCount==2 then
init()
highScore=false
start=true
end
return
end
if (t.y-yc)^2/limit^2+(t.x-xc)^2/limit^2 <= 1 then
total=total+limit
xc=-100
yc=-100
end
end
end
function showHighScore()
fill(0,0,255)
text("Double tap the screen to start",WIDTH/2,HEIGHT/2-160)
pushStyle()
fill(255)
font("Courier")
t=total
for x=1,10 do
str=string.format("popup%d",x)
h=readLocalData(str)
if h==nil then
saveLocalData(str,0)
if t>0 then
saveLocalData(str,t)
t=0
end
elseif t==tonumber(h) then
break
elseif t>tonumber(h) then
saveLocalData(str,t)
t=tonumber(h)
end
end
for x=1,10 do
str=string.format("popup%d",x)
h=readLocalData(str)
str=string.format("%2d) %4d",x,h)
text(str,WIDTH/2,800-x*35)
end
popStyle()
end