starter game 17

Here’s another game starter for anyone to use. The object is to keep the balls from falling off the screen. Tap the screen to create a red ball for a ball to bounce off of. For each ball that hits the red ball, you get 1 point. For each ball that falls off the bottom, you lose points equal to the number of balls on the screen. Keep tapping around the screen to keep the balls from falling. A new ball is created every ten seconds or anytime a ball falls off the bottom. I show your current score and the high score. Once the current score goes back to 0, the game is over and your high score is shown. Double tap the screen to play again.

displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)

function setup()
    fontSize(40)
    e1=physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT))
    e2=physics.body(EDGE,vec2(0,HEIGHT),vec2(WIDTH,HEIGHT))
    e3=physics.body(EDGE,vec2(WIDTH,HEIGHT),vec2(WIDTH,0))
    tab={}
    ball()  
    tw()  
    total=0
    maxTotal=0
    gameOver=false
end

function tw()
    t1=tween.delay(10,function() ball() tw() end)
end

function draw()
    background(31, 66, 75, 255)
    fill(255)
    text("High score  "..maxTotal,WIDTH/2,HEIGHT-100)
    if gameOver then
        text("GAME OVER",WIDTH/2,HEIGHT/2+100)
        text("Double tap screen to play again.",WIDTH/2,HEIGHT/2)
        return
    end
    text("Current  "..total,WIDTH/2,HEIGHT-50)
    for a,b in pairs(tab) do
        ellipse(b.x,b.y,40)
        if b.y<0 then
            b:destroy()
            table.remove(tab,a)
            total=total-#tab
            if total<=0 then
                gameOver=true
                return
            end
            ball()
        end
    end
    if tb~=nil then
        fill(255,0,0)
        ellipse(tb.x,tb.y,30)
    end
end

function collide(c)
    if c.state==BEGAN and not gameOver then
        if c.bodyA.info=="tball" and c.bodyB.info=="ball" or
            c.bodyA.info=="ball" and c.bodyB.info=="tball" then
            total=total+1
            maxTotal=math.max(total,maxTotal)
        end
    end
end

function touched(t)
    if t.state==BEGAN then
        if gameOver and t.tapCount==2 then
            restart()
            return
        end
        if tb then
            tb:destroy()
        end
        tb=physics.body(CIRCLE,15)
        tb.x=t.x
        tb.y=t.y
        tb.restitution=1  
        tb.info="tball"
        tb.type=STATIC      
    end
end

function ball()
    b=physics.body(CIRCLE,20)
    b.x=math.random(50,WIDTH-50)
    b.y=math.random(HEIGHT-200,HEIGHT)
    b.restitution=1
    b.info="ball"
    b.gravityScale=.5
    table.insert(tab,b)
end

terrific?ball bounce game

I like it!

Nice game, I was actually playing it as if I got it from the app store.

Thanks @dave1707 for sharing, I enjoyed playing it. Can I ask you what licence are you releasing these game starters under? Are they permissive like WTFPL or LGPL, or more restrictive? What if someone publishes a game based on your code?

@LightDye Anything posted on this forum is for public use unless otherwise stated. All of my starter games are for anyone’s use and as the name states, they are starter games for anyone to take and expand on anyway they want and to use anyway they want.