New Game Challenge: Pong/Air Hockey Variant

I like the scoring on yours @Monkeyman32123 if you put the starter into a separate tab it speeds everything up.

here’s my entry. Had to fit the code on two posts(sorry).

function setup()
displayMode(FULLSCREEN)
    ww = math.random(1,2)
     ud = nil
    hoff = true
    sud = false
    minute = 6
    sec1 = 0
    sec2 = 0
    start = false
    sSecond = 60
    sStart = 60
    x2 = WIDTH/2
    y2 = HEIGHT/2
    drct = true
    up_down = nil
    Pls = 0
    Ais = 0
    size = 40
    hit = false
    mo = 0
    AImo = 0
    gs = false
    e = false
    m = false
    h = false
    dim = false
    fade = 0
    ax = 30
    ay = HEIGHT/2 - 30
    aw = 25
    ah = 100
    x = 975
    y = HEIGHT/2 - 30
    w = 25
    hi = 100
    Pls = 0
    Ais = 0
    fade2 = 255
    go = false
    AIgo = false
    play = true
    playtime = 0
    en = 0
    es = math.random(60*30,60*40)
    ea = false
    ee = es + 540*2
    gpy = math.random(60,700)
    gpx = math.random(350,450)
    minRecx = x
    minRecy = y - 60
    switch = false
    minirect = false
    Atime = 0
    Time = 0
    bonus = math.random(1,5)
    AIminirect = false
    AIminRecx = ax
    AIminRecy = ay - 60
    check = false
end

-- This function gets called once every frame
function draw()
    if play == true then
            music("Game Music One:Zero")
            play = false
        end
    playtime = playtime + 1
    if playtime == 60*324 then
            play = true
            playtime = 0
        end
    if gs == false then
        background(0)
    fontSize(100)
    fill(255, 0, 9, fade)
    if dim == false then
    if fade < 255 then
        fade = fade + 1
    end
        if fade == 255 then
            dim = true
        end
        end
    if dim == true then
        if fade > 130 and fade <= 255 then
            fade = fade - 1
        end
        if fade == 130 then
            dim = false
        end
end
font("AcademyEngravedLetPlain")
text("Tap to play",WIDTH/2,HEIGHT/2+100)
fontSize(28)
text("choose the level of difficullty",WIDTH/2,HEIGHT/2)
fill(255, 255, 255, fade)
rect(700,200,100,40)
rect(450,200,100,40)
rect(200,200,100,40)
fill(0)
text("easy",250,220)
text("medium",500,220) 
text("hard",750,220)
    end
    if gs == true then 
    if hoff == true then
    if ww == 1 then
    hit = false
    drct = true
    end
     if ww == 2 then
     hit = true
    drct = false
    end
    hoff = false
    end
    fade = 0
    background(0)
    strokeWidth(0)
    stroke(255,156,30,fade2)
    strokeWidth(5)
    line(WIDTH/2,780,WIDTH/2,0)
    fill(0,0,0,0)
    stroke(255, 0, 0, fade2)
    ellipse(1024,HEIGHT/2,950)
    ellipse(0,HEIGHT/2,950)
    strokeWidth(0)
    fill(255, 167, 0, fade2)
    rect(x,y,25,100)
    fontSize(50)
    fill(255)
    text(minute .. ":" .. sec2 .. sec1,WIDTH/2,HEIGHT - 75)
    if sStart > -1 then
        sStart = sStart - 1 
        if sStart == 0 then
            start = true
        end
    end
        if start == true then
    if sec2 == 0 then
        sec1 = 9
        sec2 = 5
        minute = 5
        start = false
    end
            end
    if minute > 0 or sec2 > 0 or sec1 > 0 then
        if sStart <= 0 then
sSecond = sSecond - 1
            end
    if sSecond == 0 then
        sec1 = sec1 - 1
        sSecond = 60
    end
    if sec1 == -1 then
        sec2 = sec2 - 1
        sec1 = 9
    end
    if sec2 == -1 then
        minute = minute - 1
        sec2 = 5
    end
        end
    if minute == 0 and sec2 == 0 and sec1 == 0 then
        fade2 = 125
    else
        fade2 = 255
    end
    fill(0, 2, 255, fade2)
    strokeWidth(0)
    ellipse(x2,y2,size)
if minute > 0 or sec2 > 0 or sec1 > 0 then
    if e == true then
    if drct == true then
        x2 = x2 + 2
        else
        x2 = x2 - 2
    end
end
if m == true then
    if drct == true then
        x2 = x2 + 3
    else
        x2 = x2 - 3
    end
end
if h == true then
    if drct == true then
        x2 = x2 + 15
    else
        x2 = x2 - 15
    end
end
        if x2 <=975 then
        if hit == false then
    if x2 >= x - 20 and x2 < x + 20 and y2 >= y - 20  and y2 < y + 110 then
        drct = false
        sound("Game Sounds One:Block 1")
        Pls = Pls + 1
        hit = true
    end
    end
            end
    if x2 >= 60 then
    if hit == true then
    if x2 >= ax - 45 and x2 < ax + 45 and y2 >= ay - 5 and y2 < ay + 105 then
        drct = true
        sound("Game Sounds One:Block 1")
        sud = true
        ud = math.random(1,2)
        Ais = Ais + 1
        hit = false
        end
    end
end
if sud == true then
if ud == 1 then
up_down = true
end
if ud == 2 then
up_down = false
end
sud = false
end
if minirect == true then
if x2 >= minRecx - 20 and x2 < minRecx + 20 and y2 >= minRecy and y2 < minRecy + 62 then
    drct = false
    hit = true
end
end
if AIminirect == true then
    if x2 >= AIminRecx -40 and x2 < AIminRecx + 40 and y2 >= AIminRecy and y2 < AIminRecy + 62 then
        drct = true 
        hit = false
    end
end
    if x2 >= x - 20 and x2 < x + 20 then
        if y2 >= y - 20 and y2 < y + 55 then
            up_down = false
        end
        if y2 >= y + 45 and y2 < y + 110 then
            up_down = true
        end    
end
    if e == true then
        if up_down == true then
            y2 = y2 + 1
        else
        if up_down == false then
        y2 = y2 - 1
end
end
end
if m == true then
    if up_down == true then
        y2 = y2 + 3
    else
    if up_down == false then
            y2 = y2 - 3
        end
    end
end
if h == true then
    if up_down == true then
        y2 = y2 + 5 
    else
    if up_down == false then
            y2 = y2 - 5
        end
    end
end

Second slide

if check == true and drct == true and AIminirect == false then
            if bonus == 1 or bonus == 2 then
            if x2 >= gpx - 45 and x2 < gpx + 45 and y2 >= gpy - 45 and y2 < gpy + 45 then
                AIminirect = true
                sound("Game Sounds One:Pop 1")
                ee = en
            end
        end
        end
if check == true and drct == false and minirect == false then
            if bonus == 1 or bonus == 2 then
            if x2 >= gpx - 45 and x2 < gpx + 45 and y2 >= gpy - 45 and y2 < gpy + 45 then
                minirect = true
                sound("Game Sounds One:Pop 1")
                ee = en
            end
        end
        end
if check == true and drct == true then
            if bonus == 3 or bonus == 4 then
                if x2 >= gpx - 45 and x2 < gpx + 45 and y2 >= gpy - 45 and y2 < gpy + 45 then
                    sound("Game Sounds One:Radar")
                    Ais = Ais + 3
                    ee = en
                end
            end
        end
if check == true and drct == false then
            if bonus == 3 or bonus == 4 then
                if x2 >= gpx - 45 and x2 < gpx + 45 and y2 >= gpy - 45 and y2 < gpy + 45 then
                    Pls = Pls + 3
                    sound("Game Sounds One:Radar")
                    ee = en
                end
            end
        end
if check == true and drct == false and go == false and AIgo == false then
            if bonus == 5 then
                if x2 >= gpx - 45 and x2 < gpx + 45 and y2 >= gpy - 45 and y2 < gpy + 45 then
                    go = true
                    sound(SOUND_POWERUP, 5611)
                    ee = en
                end
            end
        end
if check == true and drct == true and AIgo == false and go == false then
            if bonus == 5 then
                if x2 >= gpx - 45 and x2 < gpx + 45 and y2 >= gpy - 45 and y2 < gpy + 45 then
                    AIgo = true
                    sound(SOUND_POWERUP, 5611)
                    ee = en
                end
            end
        end
if x2 > 1090 then
    x2 = WIDTH/2
    y2 = HEIGHT/2
    if Pls >= 4 then
    Pls = Pls - 4
    Ais = Ais + 4
    else
    Ais = Ais + Pls
    Pls = Pls - Pls
    end
    hit = true
    drct = false
    sound("Game Sounds One:Wrong")
end
if x2 < -50 then
            x2 = WIDTH/2
            y2 = HEIGHT/2
            if Ais >= 4 then
            Pls = Pls + 4
            Ais = Ais - 4
            else
            Pls = Pls + Ais
            Ais = Ais - Ais 
            end
            hit = false
            drct = true
            sound("Game Sounds One:Wrong")
        end
if y2 > 750 then
    up_down = false
    sound("Game Sounds One:Wall Bounce 2")
else
    if y2 < 20 then
        up_down = true
        sound("Game Sounds One:Wall Bounce 2")
    end
end
end
    if minute > 0 or sec1 > 0 or sec2 > 0 then
    en = en + 1
    if minirect == true or AIminirect == true then
    if switch == true then
        AIminRecy = ay - 60
        minRecy = y - 60
        else
        minRecy = y + 110
        AIminRecy = ay + 110
    end
    end
    
    if switch == false then
        switch = true 
        else
        switch = false
    end
    if ea == true then
        bonus = math.random(1,5)
        check = true
        ea = false
    end
    if en >= es then
        ea = true
        end 
    if check == true then
        ea = false
        if minirect == false or AIminirect == false then
        if bonus == 1 or bonus == 2 then
    sprite("Planet Cute:Gem Blue",gpx,gpy,60,80)
        end
        end
        if bonus == 3 or bonus == 4 then
    sprite("Planet Cute:Gem Orange",gpx,gpy,60,80)
        end
        if bonus == 5 then
    sprite("SpaceCute:Star",gpx,gpy,60,80) 
            end
        end
    if en >= ee then
        es = math.random(60*30,60*40)
        ee = es+540*2
        gpx = math.random(200,750)
        gpy = math.random(60,700)
        en = 0
        check = false
    end
        if minirect == true then
            rect(minRecx,minRecy,20,50)
            Time = Time + 1
        end
        if AIminirect == true then
            rect(AIminRecx,AIminRecy,20,50)
            Atime = Atime + 1
        end

        if Time == 60 * 30 then
            minirect = false
            Time = 0
        end
        if Atime == 60 * 30 then
            AIminirect = false
            Atime = 0
        end  
    end
    fill(255, 167, 0, fade2)
    if minute > 0 or sec2 > 0 or sec1 > 0 then
        if ay >= 40 and ay <= 650 then
    if e == true then
    if x2 < WIDTH/2 - 100 then
    if ay + 50 < y2 then
        ay = ay + 2
    else
        if ay + 50 > y2 then
 ay = ay - 2
 end
end
end
end
if m == true then
    if x2 < WIDTH/2 + WIDTH/4 then
        if ay + 50 < y2 then
            ay = ay + 3
        else
            if ay + 50 > y2 then
            ay = ay - 3
            end
        end
    end
end
if h == true then
        if ay + 50 < y2 then
            ay = ay + 5
        else
            if ay + 50 > y2 then
            ay = ay - 5
            end
        end
            end
            if ay >= 650 then
                ay = 649  
            end
            if ay <= 40 then
                ay = 41
            end
    end
        end
    strokeWidth(0)
rect(ax,ay,aw,ah)
    if go == true or AIgo == true then
    if go == true then
        text("Move Your Paddle Around the Screen",WIDTH/2,HEIGHT-HEIGHT+75)
        mo = mo + 1
    end
    if AIgo == true then
        AImo = AImo + 1
      if x2 <= WIDTH/2 then
            if ax <= WIDTH/2 then
                if ax+50 < x2 then
                    ax = ax + 2
                    end
                end
            end
    if x2 >= WIDTH/2 then
            if ax >= 30 then
                ax = ax - 2
            end
        end
        end
if AImo == 60 * 45 then
        AImo = 0
        AIgo = false
        ax = 30
    end
if mo == 60*45 then
        mo = 0
        go = false
        x = 975
    end   
    end
    fill(fade2)
    fontSize(50)
        font("AmericanTypewriter")
        text(Pls,WIDTH-50, HEIGHT-70)
        text(Ais,WIDTH-WIDTH + 50, HEIGHT - 70)
        fill(225)
        if minute == 0 and sec2 == 0 and sec1 == 0 then
    check = false
     if Pls > Ais then
         fontSize(100)
         fill(255)
         text("You Win", WIDTH/2,HEIGHT/2)
     elseif Pls < Ais then
         fontSize(100)
         fill(255)
         text("You Lose",WIDTH/2,HEIGHT/2)
     else
         fontSize(100)
         fill(255)
         text("Tie",WIDTH/2,HEIGHT/2)
     end
fontSize(25)
text("Tap to Play Again",WIDTH/2,HEIGHT/2-80)
end
        end
end
function touched(touch)
    if gs == false then 
        if touch.x >= 200 and touch.x < 300 and touch.y >= 200 and touch.y < 240  then
            if touch.state == BEGAN then
            sound("Game Sounds One:Menu Select")
            gs = true
            e = true
        end
    end
    if touch.x >= 450 and touch.x < 550 and touch.y >= 200 and touch.y <240 then
        if touch.state == BEGAN then
            sound("Game Sounds One:Menu Select")
            gs = true
            m = true
        end
    end
    if touch.x >= 700 and touch.x < 800 and touch.y >= 200 and touch.y < 240 then
        if touch.state == BEGAN then
            sound("Game Sounds One:Menu Select")
            gs = true
            h = true
        end
    end
end
    if minute == 0 and sec2 == 0 and sec1 == 0 then
        if gs == true then
        if touch.state == BEGAN then
            gs = false
            go = false
            AIgo = false
            ax = 30
            x = 975
            minute = 6
            sec2 = 0
            sec1 = 0
            sStart = 60
            Pls = 0
            Ais = 0
            e = false
            m = false
            h = false
            x2 = WIDTH/2
            y2 = HEIGHT/2
            ay = HEIGHT/2
            y = HEIGHT /2
            ud = nil
            up_down = nil
            ww = math.random(1,2)
            dim = false
            en = 0
            minirect = false
            AIminirect = false
        end
        end
    end
    if gs == true then
    if minute > 0 or sec2 > 0 or sec1 > 0 then
    if go == true then
        if touch.state == MOVING then
            if x >= WIDTH/2 and x <= 975 then
                x = touch.x
            end
            if x < WIDTH/2 then
             x = WIDTH/2 + 1   
            end
            if x > 975 then
             x = 974
             end
        end
    end 
    if touch.state == MOVING then
        if touch.y >= 70 and touch.y <= 700 then
        if touch.x > x- 90 and touch.x < x + 90 then 
            y = touch.y - 50
        end
                end
    end
        end
    end
        end

Enjoy

Winner will be posted Friday thanks for the submissions

So, when will the winner be posted again?

I do not have my iPad so I can’t view @Progrmr235 code so I dont know how he did.

Did it break or something?

No just not at this house it will be here Friday so tomorrow

@TheMcSebi Congratulations your AI Pong Game has one. Thank you Monkeyman and Progrmr235 for your submissions.

Thank you :slight_smile: