Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

New Game Challenge: Pong/Air Hockey Variant

edited October 2014 in Competition Posts: 103

This challenge is to make the best variation of either Pong or Air Hockey.
1) It can be similiar to the games but must have a cool twist.
2) No line limit.
3) Menu and Game Over preferred but not required
4) Prize: TBD
5) Judges: Monkeyman
6) Deadline: November 11, 2014 @ 11:11 am

Best of Luck,
Griffin

Comments

  • Whats TBD 5?

  • Posts: 135

    To be determined

  • Oh, then the 5 in there must mean rule 5.

  • What the heck, I'm bored. I'll enter.

  • What's with all the 11s in the deadline? ;)

  • I'll enter, but be warned that my entry will be too awesome for your mind to handle.

  • Posts: 103

    I still need another judge PM's please

  • Posts: 103

    We dont have enough applicants to make a decent competition. Please consider joining this.

  • Posts: 216

    I'll join, but not sure if I'll have the free time to finish writing an app

  • edited November 2014 Posts: 25

    Sorry, but how can i post a comment with a fancy box containing my code? I'm new here and couldn't find it anywhere and I wanted to share my fully functional pong variant with clever bots with you guys.

  • dave1707dave1707 Mod
    Posts: 7,650

    @TheMcSebi If you want to post your code, put 3 ~'s (tildes) on a line before and after your code.

  • Posts: 1,976

    @TheMcSebi That sounds like a frequently asked question...maybe you should read the FAQ?

  • edited November 2014 Posts: 59

    '2) No line limit.'

    What does that mean? Does it mean that the paddles should be able to go anywhere on the screen?

  • Posts: 216

    @CayDay47 , I think he means your code can be as many lines as you want.

  • edited November 2014 Posts: 25

    Couldn't find it on the FAQ, but thanks @dave1707 :)

    So this is what i did during a couple of days when I was really bored - hope you enjoy it :)

    -- Main
    
    supportedOrientations(LANDSCAPE_ANY)
    displayMode(FULLSCREEN)
    
    function setup()
    
        -- ADJUSTABLE PARAMETERS
        local toggleBot1 = true
        local toggleBot2 = false
    
        local botOperationDelay = 60    --min 3
            -- bot max speed at 3: 365
            -- bot max speed at 5: 250
        local botMovementMode = 1    -- 1 || 2
        local initialBallSpeed = 12
    
        local bouncesToSpeedIncrease = 5
        -- END OF ADJUSTABLE PARAMETERS
    
        doGameSetup(botOperationDelay, initialBallSpeed, bouncesToSpeedIncrease, botMovementMode, toggleBot1, toggleBot2)
    end
    
    
    function doGameSetup(bod, ibs, btsi, bmm, tb1, tb2)
        ball = {pos=vec2(WIDTH/2, HEIGHT/2), dir=nil, s=4}
        bars = {{x=0, y=HEIGHT/2}, {x=1, y=HEIGHT/2}}
        bot1 = {fin = nil, delay = bod, job = false, ball = nil}
        bot2 = {fin = nil, delay = bod, job = false, ball = nil}
        score = {left=0, right=0}
    
        bgc = color(31, 39, 82, 255)
        noSmooth()
    
        parameter.boolean("bot1_enabled", tb1)
        parameter.boolean("bot2_enabled", tb2)
        parameter.boolean("autorestart", false)
        parameter.integer("sysMultiply", 1, 20, 1)
        parameter.watch("ballSpeed")
    
        maxBounces = btsi
        initBallSpeed = ibs
        ballSize = 20
        barLength = 200
        borderWidth = 15
        botMode = bmm
    
        touches = {}
        bounces = 0
        gameState = 0
        ballSpeed = ibs
    end
    
    function touched(touch)
        if touch.state == ENDED then
            touches[touch.id] = nil
            started = false
        else
            touches[touch.id] = touch
        end
    end
    
    function draw()
        handleTouches()
    
        drawField()
        drawScore()
        drawBall()
    
        for i = 1, sysMultiply do
            for i = 1, ballSpeed do
                if gameState == 1 then
                    updateBall()
                end
            end
    
            if gameState == 1 then
                updateGame()
            end
    
            if bot1_enabled then bot(1) end
            if bot2_enabled then bot(2) end
        end
    
        for i,b in pairs(bars) do drawBar(b) end
    end
    
    
    function bot(n)
        -- simple bot code
        --bars[n].y = ball.pos.y + math.random((-barLength/2.1)*100, (barLength/2.1)*100)/100
    
        -- hardcore bot code
        if (n == 1) and not (bot1.ball == nil) then
            local b = bot1.ball
            --local rand = vec2(0, math.random((-barLength/2.3)*100, (barLength/2.3)*100)/100)
            local randRange = barLength/1.1
            local rand = vec2(0, math.random()*randRange-randRange/2)
            local fin = simulation(b.pos, b.dir) + rand
    
            bot1.job = true
            bot1.fin = fin
            bot1.speed = (bot1.fin.y-bars[1].y)/bot1.delay
            bot1.ball = nil
    
    
        elseif (n == 2) and not (bot2.ball == nil) then
            local b = bot2.ball
            --local rand = vec2(0, math.random((-barLength/2.3)*100, (barLength/2.3)*100)/100)
            local randRange = barLength/1.1
            local rand = vec2(0, math.random()*randRange-randRange/2)
            local fin = simulation(b.pos, b.dir) + rand
    
            bot2.job = true
            bot2.fin = fin
            bot2.speed = (bot2.fin.y-bars[2].y)/bot2.delay
            bot2.ball = nil
        end
    
        if (bot1.job == true) and (n == 1) then
            if botMode == 1 then
                bars[1].y = bars[1].y + bot1.speed
            elseif botMode == 2 then
                bars[1].y = bars[1].y + (bot1.fin.y - bars[1].y)/(bot1.delay/2.2)
            end
            if math.floor(bot1.fin.y*10) == math.floor(bars[1].y*10) then
                bars[1].y = bot1.fin.y
                bot1.job = false
                --print("bot1 job done")
            end
        end
    
        if (bot2.job == true) and (n == 2) then
            if botMode == 1 then
                bars[2].y = bars[2].y + bot2.speed
            elseif botMode == 2 then
                bars[2].y = bars[2].y + (bot2.fin.y - bars[2].y)/(bot1.delay/2.2)
            end
            if math.floor(bot2.fin.y*10) == math.floor(bars[2].y*10) then
                bars[2].y = bot2.fin.y
                bot2.job = false
                --print("bot2 job done")
            end
        end
    
    end
    
    function simulation(startPos, direction)
        local pos = startPos
        local dir = direction
        local targetReached = false
    
        while not targetReached do
            pos = pos + dir:normalize()
    
            if pos.y > HEIGHT-borderWidth-ballSize/2 then
                dir = vec2(dir.x, -dir.y)
                pos.y = HEIGHT-borderWidth-ballSize/2
            elseif pos.y < borderWidth+ballSize/2 then
                dir = vec2(dir.x, -dir.y)
                pos.y = borderWidth+ballSize/2
            end
    
            if pos.x > WIDTH-borderWidth-ballSize/2 then
                -- rechts
                targetReached = true
            elseif pos.x < borderWidth+ballSize/2 then
                -- links
                targetReached = true
            end
        end
    
        return pos
    end
    
    
    function updateGame()
        if bounces >= maxBounces then
            bounces = 0
            ballSpeed = ballSpeed + 1
        end
    end
    
    
    function handleTouches()
    
        local x = 0
        local y = 0
    
        for k,touch in pairs(touches) do
            x = touch.x
            y = touch.y
    
            for i,b in pairs(bars) do
                if x < WIDTH/2 then
                    if b.x == 0 then
                        b.y = y
                    end
                elseif x > WIDTH/2 then
                    if b.x == 1 then
                        b.y = y
                    end
                end
            end
        end
    
        if gameState == 0 then
    
            local bpos = ball.pos
    
            local dist = bpos:dist(vec2(x, y))
            if (dist < ballSize*3) or autorestart then
                gameState = 1
    
                local buffer = math.random(1, 2)
                local yDir = math.random()*12-6
    
                if buffer == 1 then
                    ball.dir = vec2(-3, yDir)
                    bot1.ball = ball
                elseif buffer == 2 then
                    ball.dir = vec2(3, yDir)
                    bot2.ball = ball
                end
            end
        end
    end
    
    
    function updateBall()
        local pos = ball.pos
        local dir = ball.dir
    
        pos = pos + dir:normalize()
    
        local x = pos.x
        local y = pos.y
    
        local passToBot1 = false
        local passToBot2 = false
    
        -- oben + unten
        if y > HEIGHT-borderWidth-ballSize/2 then
            dir = vec2(dir.x, -dir.y)
            pos.y = HEIGHT-borderWidth-ballSize/2
        elseif y < borderWidth+ballSize/2 then
            dir = vec2(dir.x, -dir.y)
            pos.y = borderWidth+ballSize/2
        end
    
        if x > WIDTH-borderWidth-ballSize/2 then
            -- rechts
            local barY = bars[2].y
            local ballY = ball.pos.y
    
            if math.abs(barY-ballY) < barLength/2 then
                dir = vec2(-dir.x, (ballY-barY)/20)
                pos.x = WIDTH-borderWidth-ballSize/2
    
                if bot1_enabled then
                    passToBot1 = true
                end
            else
                scorePoint(2)
                pos = vec2(WIDTH/2, HEIGHT/2)
            end
    
            bounces = bounces + 1
    
        elseif x < borderWidth+ballSize/2 then
            -- links
            local barY = bars[1].y
            local ballY = ball.pos.y
    
            if math.abs(barY-ballY) < barLength/2 then
                dir = vec2(-dir.x, (ballY-barY)/20)
                pos.x = borderWidth+ballSize/2
    
                if bot2_enabled then
                    passToBot2 = true
                end
            else
                scorePoint(1)
                pos = vec2(WIDTH/2, HEIGHT/2)
            end
    
            bounces = bounces + 1
        end
    
        ball.pos = pos
        ball.dir = dir
    
        if passToBot1 then
            bot1.ball = ball
        end
    
        if passToBot2 then
            bot2.ball = ball
        end
    end
    
    
    function drawField()
        background(bgc)
    
        pushMatrix()
        pushStyle()
    
        rectMode(CENTER)
        stroke(255, 255, 255, 255)
        strokeWidth(borderWidth)
        lineCapMode(SQUARE)
        fill(bgc)
        translate(WIDTH/2, HEIGHT/2)
    
        rect(0, 0, WIDTH+300, HEIGHT)
        stroke(255, 255, 255, 106)
        line(0, -HEIGHT/2, 0, HEIGHT/2)
    
        popMatrix()
        popStyle()
    end
    
    
    function drawBall()
        pushMatrix()
        pushStyle()
    
        local x = ball.pos.x
        local y = ball.pos.y
    
        rectMode(CENTER)
        fill(255, 255, 255, 255)
    
        rect(x, y, ballSize, ballSize)
    
        popMatrix()
        popStyle()
    end
    
    function drawBar(bar)
        pushMatrix()
        pushStyle()
    
        local h = barLength
        local w = borderWidth
        local x = bar.x*(WIDTH-w)+w/2
        local y = bar.y
    
        rectMode(CENTER)
        fill(255, 255, 255, 255)
    
        rect(x, y, w, h)
    
        popMatrix()
        popStyle()
    end
    
    
    function scorePoint(side)
        if side == 1 then
            --print("point for right")
            score.right = score.right + 1
        elseif side == 2 then
            --print("point for left")
            score.left = score.left + 1
        end
    
        gameState = 0
        ballSpeed = initBallSpeed
    end
    
    
    function drawScore()
        local size = 50
        local str = score.left.."   "..score.right
    
        pushMatrix()
        pushStyle()
        fill(255, 255, 255, 255)
        fontSize(size)
        font("Arial-BoldMT")
        textMode(CENTER)
        text(str, WIDTH/2, HEIGHT-borderWidth-size/2)
        popMatrix()
        popStyle()
    end
    

    Edit: Oooooohh, THAT FAQ.... I only found that on the wiki ._. Sorry again...

  • I'll give this one a try but it won't be soo great!

  • @Mr_Ninja, thanks for making me see the obvious thing I overlooked :)
    It's funny, I was already thinking about how to do it by then.

  • Posts: 103

    Great game @TheMcSebi I really liked how you made the "AI" for the players. Remember all others deadline for game is Remembrance Day at 11:11

  • edited November 2014 Posts: 342

    Here's my version, somewhat sloppily done, which I'm not proud of, but I like the visuals, so there is that. I was going to add more features, but I've been strapped for time, I may still add them.

    displayMode(OVERLAY)
    displayMode( FULLSCREEN)
    supportedOrientations(LANDSCAPE_ANY)
    
    function setup()
        physics.continuous=true
        p1=physics.body(CIRCLE,50)
        p1.mass=1
        p1.sleepingAllowed=false
        p1.bullet=true
        p1.position = vec2(50,HEIGHT/2)
        p1.lastpos = p1.position
        p1.name = "paddle1"
        p1.gravityScale = 0
        p1.type = KINEMATIC
        p1.draw = function()
            pushStyle()
            stroke(255,63.75,0)
            strokeWidth(score2/10*(p1.radius))
            fill(0, 255, 255, 255)
            ellipse(p1.x,p1.y,p1.radius*2+2)
            popStyle()
        end
        p2=physics.body(CIRCLE,50)
        p2.mass = 1
        p2.sleepingAllowed=false
        p2.bullet=true
        p2.position = vec2(WIDTH-50,HEIGHT/2)
        p2.lastpos = p2.position
        p2.name = "paddle2"
        p2.gravityScale = 0
        p2.type = KINEMATIC
        p2.draw = function()
            pushStyle()
            stroke(0,255,255)
            strokeWidth(score1/10*(p2.radius))
            fill(255, 63.75, 0, 255)
            ellipse(p2.x,p2.y,p2.radius*2+2)
            popStyle()
        end
        p3=physics.body(CIRCLE,20)
        p3.linearDamping=.25
        p3.mass = 1000
        p3.sleepingAllowed=false
        p3.bullet=true
        p3.position = vec2(WIDTH/2,HEIGHT/2)
        p3.name = "ball"
        p3.gravityScale = 0
        p3.type = DYNAMIC
        p3.draw = function()
            pushStyle()
            noStroke()
            fill(color(255,63.75,0):mix(color(0,255,255),.5+(score2-score1)/20))
            ellipse(p3.x,p3.y,p3.radius*2+2)
            popStyle()
        end
        maxlinedash = 33.3
        score1 = 0
        gs1=0
        score2 = 0
        gs2=0
        fps=60
        s=Starter()
        s:start(false)
    
    end
    function draw()
        background(127.5)
        strokeWidth(10)
        stroke(255, 63.75, 0, 255)
        lineCapMode(ROUND)
        for i=-2,maxlinedash do
            if i%2==0 then
                line(WIDTH/2,(i/maxlinedash)*HEIGHT+(ElapsedTime*10)%(HEIGHT/(maxlinedash/2)),WIDTH/2,(i+1)/maxlinedash*HEIGHT+(ElapsedTime*10)%(HEIGHT/(maxlinedash/2)))
            end
        end
        clip(WIDTH/2+(score2-score1)*10,0,WIDTH/2,HEIGHT)
        stroke(0, 255, 255, 255)
        for i=-2,maxlinedash do
            if i%2==0 then
                line(WIDTH/2,(i/maxlinedash)*HEIGHT+(ElapsedTime*10)%(HEIGHT/(maxlinedash/2)),WIDTH/2,(i+1)/maxlinedash*HEIGHT+(ElapsedTime*10)%(HEIGHT/(maxlinedash/2)))
            end
        end
        clip()
        if p3.position.y > HEIGHT-p3.radius then
            p3.linearVelocity = vec2(p3.linearVelocity.x,math.min(-p3.linearVelocity.y,p3.linearVelocity.y))
            elseif p3.position.y < p3.radius then
            p3.linearVelocity = vec2(p3.linearVelocity.x,math.max(-p3.linearVelocity.y,p3.linearVelocity.y))
        end
        if p3.position.x > WIDTH+p3.radius then
            score1 = score1 + 1
            if score1 >= 11 then 
                score1 = 0
                gs1 = gs1 + 1
            end
            p3.linearVelocity=vec2(0,0)
            p3.position=vec2(WIDTH/2,HEIGHT/2)
            s:start(false)
        end
        if p3.position.x < -p3.radius then
            score2 = score2 + 1
            if score2 >= 11 then 
                score2 = 0
                gs2 = gs2 + 1
            end
            p3.linearVelocity=vec2(0,0)
            p3.position=vec2(WIDTH/2,HEIGHT/2)
            s:start(true)
        end
        if touch2 then p2.position = vec2(touch2.x,touch2.y) end
        if touch1 then p1.position = vec2(touch1.x,touch1.y) end
        if p2.position.x < WIDTH/2+p3.radius+p2.radius then
            p2.position=vec2(WIDTH/2+p3.radius+p2.radius,p2.position.y)
            p2.linearVelocity.x =0
        end
        if p2.linearVelocity.x < (WIDTH/2+p3.radius+p2.radius)-p2.position.x then
            p2.linearVelocity.x = (WIDTH/2+p3.radius+p2.radius)-p2.position.x
        end
        if p1.position.x > WIDTH/2-p3.radius-p1.radius then
            p1.position=vec2(WIDTH/2-p3.radius-p1.radius,p1.position.y)
            p1.linearVelocity.x =0
        end
        if p1.linearVelocity.x > (WIDTH/2-p3.radius-p1.radius)-p1.position.x then
            p1.linearVelocity.x = (WIDTH/2-p3.radius-p1.radius)-p1.position.x
        end
        if p3.linearVelocity:len() > 1500 then
            p3.linearVelocity = 1500/p3.linearVelocity:len()*p3.linearVelocity
        end
        s:draw()
        p3:draw()
        p1:draw()
        p2:draw()
        fontSize(50)
        textAlign(RIGHT)
        fill(0,255,255)
        local w,h = textSize(score1.."\n"..gs1)
        text(score1.."\n"..gs1,WIDTH/2-w/2-15,HEIGHT-h/2)
        fill(255,63.75,0)
        local w,h = textSize(score2.."\n"..gs2)
        text(score2.."\n"..gs2,WIDTH/2+w/2+15,HEIGHT-h/2)
        output.clear()
        fps=.9*fps+.1*(1/DeltaTime)
        print(math.floor(fps))
    end
    function touched(t)
        if not touch1 and t.state == BEGAN and p1.position:dist(vec2(t.x,t.y))<p1.radius then
            touch1 = t
            elseif not touch2 and t.state == BEGAN and p2.position:dist(vec2(t.x,t.y))<p2.radius then
            touch2 = t
        end
        if t.state == MOVING and touch1 and t.id == touch1.id then
            p1.lastpos = p1.position
            touch1=t
            p1.linearVelocity = 1*vec2(30*t.deltaX,30*t.deltaY)
            if p1.linearVelocity.x > (WIDTH/2-p3.radius-p1.radius)-p1.position.x then
                p1.linearVelocity.x = (WIDTH/2-p3.radius-p1.radius)-p1.position.x
            end
            elseif t.state == MOVING and touch2 and t.id == touch2.id then
            p2.lastpos = p1.position
            touch2=t
            p2.linearVelocity = 1*vec2(30*t.deltaX,30*t.deltaY)
            if p2.linearVelocity.x < -(WIDTH/2+p3.radius+p2.radius)+p2.position.x then
                p2.linearVelocity.x = (WIDTH/2+p3.radius+p2.radius)-p2.position.x
            end
        end
        if t.state == ENDED and touch1 and touch1.id == t.id then
            touch1 = nil
            p1.linearVelocity=vec2(0,0)
            elseif t.state == ENDED and touch2 and t.id == touch2.id then
            touch2 = nil
            p2.linearVelocity=vec2(0,0)
        end
    end
    
    Starter = class()
    
    function Starter:init()
        self.target = vec2(WIDTH/2,HEIGHT/2)
        self.d=100
        self.del = 2
        self.active = false
        self.left = true
        self.t=0
        self.on = false
    end
    
    function Starter:draw()
        if self.active then
            if self.t<self.del then
                self.t = self.t + DeltaTime
                else
                self.on=true
            end
            if self.on then
                p3.type=DYNAMIC
                if self.left ==true then
                    p3.linearVelocity=vec2(500,0):rotate(math.rad(math.random(115,245)))
                    else
                    p3.linearVelocity=vec2(500,0):rotate(math.rad(65-math.random(130)))
                end
                self.active,self.on=false,false
            end
        end
    end
    
    function Starter:start(left)
        self.left = left
        self.t=0
        self.active = true
        p3.type=STATIC
    end
    
  • Posts: 103

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

  • edited November 2014 Posts: 103

    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
    
  • edited November 2014 Posts: 103

    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

  • Posts: 103

    Winner will be posted Friday thanks for the submissions

  • So, when will the winner be posted again?

  • Posts: 103

    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?

  • Posts: 103

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

  • Posts: 103

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

  • Thank you :)

Sign In or Register to comment.