Here’s another game starter someone can take and improve on. Tilt the ipad right or left to hit the ball and get the score above the bar. If you miss a ball, the size of the bar and value goes down by 1. Game over at 0. Double tap to restart.
displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)
function setup()
gameOver=false
rectMode(CENTER)
size=50
score=0
count=200
rx=WIDTH/2
tab={}
end
function draw()
background(40, 40, 50)
stroke(255)
strokeWidth(2)
line(0,100,WIDTH,100)
line(0,700,WIDTH,700)
line(WIDTH/2,700,WIDTH/2,100)
for z=1,15 do
line(WIDTH/2-z*120,100,WIDTH/2-z*40,700)
line(WIDTH/2+z*120,100,WIDTH/2+z*40,700)
end
if gameOver then
fill(255)
text("Game Over",WIDTH/2,HEIGHT/2)
text("Double tap to restart",WIDTH/2,HEIGHT/2-50)
else
fill(255)
for a,b in pairs(tab) do
ellipse(b.x,b.y,b.z*((750-b.y)/600))
b.y=b.y+b.w
b.x=b.x+(WIDTH/2-b.x)/650
b.w=b.w-.0005
if b.y>=700 then
if b.x>rx-size/2 and b.x<rx+size/2 then
score=score+size
else
size=size-1
end
table.remove(tab,a)
end
end
count=count+1
if count>90 then
table.insert(tab,vec4(math.random(WIDTH/2-1000,WIDTH/2+1000),125,50,1))
count=0
end
if size<1 then
gameOver=true
end
rect(rx,705,size,10)
rx=rx+Gravity.x*50
if rx<size/2 then
rx=size/2
end
if rx>WIDTH-size/2 then
rx=WIDTH-size/2
end
fill(0,255,0)
text(size,rx,720)
end
fill(255,0,0)
text("SCORE "..score,WIDTH/2,HEIGHT-20)
end
function touched(t)
if t.state==BEGAN and t.tapCount==2 then
restart()
end
end