Howdy, Stranger!

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

100 Lines of Code Challenge!

edited October 2014 in Competition Posts: 300

Hey everyone!

Everyone has probably seen the 50 lines of code challenge, which had some interesting games made in it. Most of the games were really limited by the 50 line requirement and didn't have start menus or anything like that. I was thinking that maybe we should do a 100 line challenge, but it has to be a complete game with start menu, try again screen, music(), sound(), score/high score, etc.

I think it would be a good learning experience to see how people do different aspects of making a game.

The only rules is the game must be under 100 lines of neat code (no multiple codes in a single line), and must use Codea assets.

I will be working on my submission.

Look forward to seeing what you guys come up with!

Edit: I'm going to add one leeway, you can add multiple end commands on one line.

Comments

  • I'll be entering in this one for sure :)
    That said, you should move it to the "competition" area instead of the general one :P

  • edited October 2014 Posts: 282

    You have no idea how long I have been waiting for a competition. I'll cook up something. ;)


    To quote @Briarfox, "Can http be used ? >:)"

  • To quite noone... "can we use loadstring to read code from a saved file? XD"

  • I'll give it a go!

  • edited October 2014 Posts: 300

    No outside links, Codea assets only.

    Tyrian has a bunch of decent assets. Hardest part will be a good background.

  • Posts: 216

    I think I'll give this a try. just need to come up with an idea that can fit within that :).

  • edited October 2014 Posts: 41

    At the instant I thought of cookie clicker, but that's just pretty basic and not very amusing. I'll try to think of other better stuff :-)

  • edited October 2014 Posts: 300

    Yeah it's going to be a challenge to think of a game simple enough.

  • Posts: 300

    Added one leeway, can add multiple end commands to a single line. End commands take up a lot of lines. :D

  • Posts: 1,976

    I feel like these "x lines of code challenges" are a bit repetitive. 50 lines was a good amount, enough to make a project, but little so you must work to make it fit. I feel like it would be a bit hard to come up with a project of 100 lines, it seems either all or nothing.

    I also don't like the restrictions of it having to be a game with menus, why not a paint program, or a simple game without a menu (if you have no options or anything, what's the point of a menu with only one button?)

  • edited October 2014 Posts: 300

    The menus make it more polished, and allow you to have a final score, high score, game title, etc. I guess it will just show the potential of codea when you could make a complete game in under 100 lines.

    Also I think a lot of people (myself included) start projects, but don't actually complete them.. maybe this will push people to complete their projects.

    The main reason I wanted to start a new x lines of code challenge is because in the 50 lines challenge a lot of people were adding multiple codes per line, which kind of ruined the idea of only 50 lines.

    I guess I see it as a learning experience, seeing how different people tackle the same challenges.

    You don't have to participate if you don't want to. :-*

  • dave1707dave1707 Mod
    edited October 2014 Posts: 7,057

    @Crumble If you want to see how people tackle the same challenges, why not pick a subject and have people write code to do it. For instance, shuffle a deck of cards, move a sprite around the screen in a specific pattern, create an exploding ship with multiple parts, show menu pages, etc. In other words, things that people might need when they create a game or other type program. That way they see different programming styles and how one way might be a better option than another and why.

    EDIT: There doesn't have to be a line limit for that.

  • edited October 2014 Posts: 300

    I think what is happening is that the experienced coders that have no problem writing a program with 1,000+ lines of code don't feel challenged by something like this, or feel extremely limited.

    However there are a lot newbies like myself, where writing a 100 line game is an accomplishment.

    I wouldn't even know where to start on a card shuffling program, etc. that stuff is way over my head.

    I guess this challenge is focused toward beginners like myself..

  • dave1707dave1707 Mod
    Posts: 7,057

    @Crumble Sorry, I misunderstood what you were saying. I guess I was taking your comment, "seeing how different people tackle the same challenges" too literally. I was looking at it as a specific challenge, where your challenge was the 100 lines. I guess I've been programming so long that I actually think in code. When someone says something, the code is already written in my head, I just need to type it out.

  • Posts: 300

    @dave1707 I definitely think that specific challenges like that would be an awesome thing. It's just way over my head right now. I wouldn't mind seeing you pros do something like that, I'm sure I would learn a lot from it.

  • dave1707dave1707 Mod
    Posts: 7,057

    @Crumble I'm not really looking for challenges, I had too many years of that already. I'm just here to help.

  • Uh, I'm interesting in this challenge. Is it too late to enter?

  • dave1707dave1707 Mod
    Posts: 7,057

    @Progrmr235 I don't think it's too late to enter.

  • Then sign me up

  • edited October 2014 Posts: 300

    Nah there isn't really a time limit. The thread got kind of derailed, hopefully a mod can clean it up..

    I'm still working on my 100 line game, been busy last 2 days

  • I'm almost done with mine (I have too much free time) there's a lot of bugs though I have fix.

  • What does it mean that you can't have multiple codes In one line?

  • edited October 2014 Posts: 103

    Like is this not allowed?

    1.) If t == true then X = X - 1 end
    

    Or is this isn't allowed?

    2.)X = 20 Y = 500 If t == true X = X - 1 end ellipse(X,Y,60)
    

    And would this not be allowed

    3.)If n == 1 then (do something) else if n == 2 then (do something) end end
    
  • Posts: 135

    I would think that the first one would be allowed

  • edited October 2014 Posts: 300

    Those are a little iffy, especially the second two...

    In neat code the first one would be more like:


    If t == true then x = x - 1 end
  • edited October 2014 Posts: 134

    My Submission: The Falling Spectrum. Dodge the rain. (Portrait)

    May have bunched a few single line if statements together, or a couple pushStyle/popStyles sharing lines, but I did spend 3 hours on this do please don't be too critical about that. Let me know what you guys thing ^.^ I may develop it a tad further into the App Store.

    function setup()
        displayMode(FULLSCREEN)
        supportedOrientations(PORTRAIT_ANY)
        mode = Classic()
        score = 0
        hs = readLocalData("highscore") or 0
        time = os.clock()
        fontSize(80)  
        song = music("Game Music One:Smoothie", true)  
    end
    function draw()
        background(255, 255, 255, 255)
        mode:draw()
    end
    function touched(t)
        if mode ~= nil then mode:touched(t) end
    end
    function collide(c)
        if c.bodyA.id == mode.ball.id or c.bodyB.id== mode.ball.id then
            mode.gameOver = true
            physics.pause()
            if score > hs then hs = score
            saveLocalData("highscore", hs)  end
        end
    end
    Classic = class()
    function Classic:init()
        self.ball = physics.body(CIRCLE, 50)
        self.ball.x,self.ball.y = WIDTH/5 * 2 + WIDTH/10,350
        self.ball.gravityScale = 0
        self.ball.color = color(127,127,127)
        self.ball.id = 69
        self.drops = {}
        self.fade = 255
        self.gameOver = false
    end
    function Classic:draw()
        makeRain()
        text(score, WIDTH/2, HEIGHT*.5)
        pushStyle()
        for a,b in pairs(self.drops) do
            if b.y < WIDTH/5 + b.radius*2 + 10 then fill(b.color) else fill(127,127,127) end
            ellipse(b.x,b.y,b.radius * 2)
        end   
        fill(self.ball.color)
        ellipse(self.ball.x, self.ball.y, self.ball.radius * 2)
        popStyle()
        for a = 1, 7 do
            rect((a-1) * WIDTH/5, HEIGHT/5, WIDTH/5, WIDTH/10)
        end
        if not self.gameOver and self.fade > 0 then
            pushStyle() 
            fill(255, 255, 255, self.fade)
            rect(0,0, WIDTH, HEIGHT) 
            popStyle()
            self.fade = self.fade - 2
        end
        if self.gameOver then
            pushStyle()
                fill(255, 255, 255, self.fade)
                rect(0,0,WIDTH, HEIGHT)
                self.fade = self.fade + 1.5
            popStyle()
            fill(127, 127, 127, self.fade)
            if self.fade > 255 then fill(127) end
            fontSize(50)
            text("High Score: "..hs, WIDTH/2, HEIGHT * .75)
            text("".."And So The \nStory Ended", WIDTH/2, HEIGHT*.5)
            ellipse(WIDTH/2, HEIGHT/5, HEIGHT/5)
            fill(255, 255, 255, 255)
            text("AGAIN",WIDTH/2, HEIGHT/5)
        end
        pushStyle()   fontSize(50)
        text("By Kirk Zimmer", WIDTH* .75, HEIGHT *.05)
        popStyle()
    end
    function Classic:touched(t)
        self.ball.x = math.floor((t.x) /(WIDTH/5)) *WIDTH/5 + WIDTH/10
        if self.gameOver and vec2(t.x,t.y):dist(vec2(WIDTH/2, HEIGHT/5)) < HEIGHT/10 then restart() end
    end
    function makeRain()
        for a = 1, #mode.drops do
            if mode.drops[a].y < -100 then
                mode.ball.color = color(mode.drops[a].color.r, mode.drops[a].color.g, mode.drops[a].color.b, 20):blend(mode.ball.color)
                mode.drops[a]:destroy()
                mode.drops[a] = nil
                table.remove(mode.drops, a)
                score = score + 1
                break
            end
        end
        if #mode.drops < 40 and #mode.drops <= (score* 2) and math.random(100) <= (1 + score/10) and os.clock() - time > .05 then
            local drop = physics.body(CIRCLE, math.random(20,WIDTH/30))
            drop.x,drop.y = WIDTH/5 * (math.random(5)-1)+ WIDTH/10,HEIGHT* 1.2
            drop.gravityScale = .09 + score*.006
            drop.color = color(math.random(100,230), math.random(80,255), math.random(100,230), 255)
            table.insert(mode.drops, drop)
            time = os.clock()
        end
    end
    
  • Jmv38Jmv38 Mod
    Posts: 3,278

    nice. maybe: 1/ make positions non-integer? 2/ press right/left to move the paddle?

  • Here is my entry.



    Warnings: Difficult (I might make it easier), and there's a glitch where you might get 0.02 or 0.03, just try again.




    Touch to move the player, don't let the player touch the enemy balls or the sides!



    Code:

    -- 100 Line Challenge
    supportedOrientations(LANDSCAPE_ANY)
    displayMode(FULLSCREEN)
    function setup()
        physics.continuous=true
        fsm="menu"
        eBalls={}
        physics.gravity(0,0)
        edges={physics.body(EDGE, vec2(0,0), vec2(WIDTH, 0)), physics.body(EDGE, vec2(0,0), vec2(0, HEIGHT)), physics.body(EDGE, vec2(0, HEIGHT), vec2(WIDTH, HEIGHT)), physics.body(EDGE, vec2(WIDTH, HEIGHT), vec2(WIDTH, 0))}
        player=physics.body(CIRCLE, 20)
        player.info="the player"
        player.position=vec2(WIDTH/2, HEIGHT/2)
        font("HelveticaNeue-UltraLight")
        fontSize(80)
        textAlign(CENTER)
        aToucher=false
    end
    function draw()
        background(0, 0, 0, 255)
        fill(255, 255, 255, 255)
        if fsm=="menu" then
            text("100 Line Game: Death Balls", WIDTH/2, HEIGHT/4*3)
            text("START", WIDTH/2, HEIGHT/2-100)
            fill(255, 50)
            ellipse(WIDTH/2, HEIGHT/2-100, 400)
        end
        if fsm=="setup" then
            scoreTimer=0
            for i=1,#eBalls do
                eBalls[i].p:destroy()
                eBalls[i]=nil
            end
            for i=1,50 do
                table.insert(eBalls, Ball(10, math.random(10, HEIGHT-10)))
            end
            fsm="playing"
        end
        if fsm=="playing" then
            scoreTimer = scoreTimer + DeltaTime
            for a,b in pairs(eBalls) do         
                b:draw()
            end
            fill(0, 0, 255, 255)
            ellipse(player.x, player.y, 40)
            player.position=vec2(CurrentTouch.x, CurrentTouch.y)
        end
        if fsm=="dead" then
            text("You lasted:\n"..string.format("%.2f", scoreTimer).." seconds", WIDTH/2, HEIGHT/3*2)
            text("AGAIN", WIDTH/2, HEIGHT/3)
            fill(255, 50)
            ellipse(WIDTH/2, HEIGHT/3, 300)
        end
    end
    function touched(t)
        if fsm=="menu" and t.state==ENDED and t.x>WIDTH/2-200 and t.x<WIDTH/2+200 and t.y<HEIGHT/2+200 and t.y>HEIGHT/2-200 then
            fsm="setup"
        end
        if fsm=="dead" then
            if t.state==BEGAN and aToucher==false then
                aToucher=true
            end
            if t.state==ENDED and aToucher and t.x>WIDTH/2-150 and t.x<WIDTH/2+150 and t.y<HEIGHT/3+150 and t.y>HEIGHT/3-150 then
                fsm="setup"
            end
        end
    end
    function collide(c)
        if fsm=="playing" then
            if c.bodyA.info~=nil or c.bodyB.info~=nil then
                fsm="dead"
            end
        end
    end
    Ball = class()
    function Ball:init(x, y)
        self.p=physics.body(CIRCLE, 10)
        self.p.friction=0
        self.p.restitution=1
        self.p.position=vec2(x, y)
        self.p.bullet=true
        self.p.linearVelocity=vec2(math.random(-500, 500), math.random(-500, 500))
    end
    function Ball:draw()
        fill(255, 255, 255, 255)
        ellipse(self.p.x, self.p.y, 20)
    end
    
  • @jmv I thought about both, but I liked the idea that the player teleports, and I really like the fixed locations. ^.^

  • Posts: 300

    Both of those are pretty fun games! Good job guys! I need to finish mine up.

  • Here's a game I made for a fifty line challenge that I never got to enter (note: not my actual entry, just for fun). Rotate the circle to collect the red dots, don't lift your finger or let the red ones get to the center or you lose!

    function setup()
        if not readLocalData("highscore") then saveLocalData("highscore",0) end
        t,tt,e,score,angle=0,ElapsedTime,{},0,math.pi/2
    end
    function draw() 
        if ElapsedTime-t > 2-(1*(tt/120)) then
            q,t = (math.random()-.5)*math.pi,ElapsedTime
            if math.random()>.5 then
                e[#e+1],e[-#e-1]=vec2(WIDTH/2+700*math.cos(q),HEIGHT/2+700*math.sin(q)),-5
            else
                e[#e+1],e[-#e-1]=vec2(WIDTH/2+700*math.cos(q+math.pi/2),HEIGHT/2+700*math.sin(q+math.pi/2)),5
            end
        end
        tt = tt + DeltaTime
        if tt>60 then tt=60 end
        background(40, 40, 50)
        fill(0,0)
        stroke(255)
        strokeWidth(5)
        ellipse(WIDTH/2,HEIGHT/2,300)
        strokeWidth(100)
        ellipse(WIDTH/2+150*math.cos(angle),HEIGHT/2+150*math.sin(angle),50)
        stroke(255,0,0)
        for a=#e,1,-1 do
            e[a]=e[a]+vec2(e[-a],0):rotate(math.atan2(e[a].y-HEIGHT/2,e[a].x-WIDTH/2))
            if e[a]:dist(vec2(WIDTH/2,HEIGHT/2)) < 50 then
                ishighscore(true)
                table.remove(e,a)
            elseif e[a]:dist(vec2(WIDTH/2+150*math.cos(angle),HEIGHT/2+150*math.sin(angle))) < 40 then
                score = score + 1
                ishighscore()
                table.remove(e,a)
            else
                ellipse(e[a].x,e[a].y,30)
            end
        end
        fill(255)
        fontSize(100)
        text(score,WIDTH/2,HEIGHT/2)
        fontSize(20)
        text(readLocalData("highscore"),WIDTH/2,HEIGHT-20)
    end
    function touched(t)
        angle = (math.atan2(t.y-HEIGHT/2,t.x-WIDTH/2))
        if t.state==ENDED or t.state==CANCELLED then ishighscore(true) end
    end
    function ishighscore(reset)
        if score>readLocalData("highscore")then saveLocalData("highscore",score)end
        if reset then score,tt=0,0 end
    end
    
  • dave1707dave1707 Mod
    Posts: 7,057

    @Saturn031000 I added 2 lines of code to your program to show you what the cause is that you're getting .02 or .03 . When the game ends, the ball is still moving around the screen. If it collides with the edge of the screen and you restart the game, you get the .02 .03 error. See the 2 lines below in the "if fsm" that I added the comment to.

        if fsm=="dead" then
            text("You lasted:\n"..string.format("%.2f", scoreTimer).." seconds", WIDTH/2, HEIGHT/3*2)
            text("AGAIN", WIDTH/2, HEIGHT/3)
            fill(255, 50)
            ellipse(WIDTH/2, HEIGHT/3, 300)
    
            fill(255)   -- added this line
            ellipse(player.x, player.y, 40)   -- added this line
    
        end
    
  • edited October 2014 Posts: 103

    Hey guys, here's my submission to the 100 line challenge. The game is pretty simple. Use the touch screen to move the ship. Try to avoid space mines. Each one you hit costs a life.

    function setup()
        displayMode(FULLSCREEN)
        x = WIDTH/2
        y = HEIGHT/2
        Otime = 0
        Ocount = 1
        gS = false
        fade = 0
        minScore = 0
        score = 0
        lives = 10
        plusLev = 50
        levBounus = false
        pluslives = 50
        level = 0
        adlives = false 
        l = true
        m2 = 0
        Star = {}
        Obs = {}
    end
    function O()
        obs = {x = 1050,y = math.random(0,750)}
        table.insert(Obs,obs)
    end
    function S()
        star = {x = 1050, y = math.random(0,750), w = math.random(2,10)}
        table.insert(Star,star)
    end
    function draw()
        background(0)
        m2 = m2 + 1 -- this plays music in infinite loop
            if m2 == 60 * 161 then l = true m2 = 0 end
            if l == true then  music("Game Music One:Pulsar") l = false end 
        if gS == false then -- this set condition for start screen
            if fade < 255 then fade = fade + 1 end
            fill(0, 255, 246, fade)
            fontSize(100)
            text("Tap to play",WIDTH/2,HEIGHT/2)
        end
        if gS == true then -- this sets condition for game
        S()
            fill(255)
            fontSize(25)
        text(lives,WIDTH-WIDTH+50,HEIGHT-50)
        sprite("SpaceCute:Health Heart",WIDTH-WIDTH+75,HEIGHT-50,20,20)
            text(score,WIDTH-50,HEIGHT-50)
            if score >= plusLev*2 and score <= plusLev*2+10 then -- set levels
                table.remove(Obs,i)
                if levBonus == true then level = level + 1 Ocount = Ocount + .5 levBonus = false end
                if score == plusLev*2+10 then plusLev = plusLev + 50 end
                text("Level "..level.. " Complete",WIDTH/2,HEIGHT/2)
            end
            minScore = minScore + .1 -- paces score count
                if minScore >= 1 then score = score + 1 minScore = 0 end
            if score == pluslives then adlives = true pluslives = pluslives + 50 end
            if adlives == true then lives = lives + 1 adlives = false levBonus = true end
            fade = 0
        Otime = Otime + DeltaTime -- timer to draw obstical in increments
        if Otime > 1/Ocount then O() Otime = 0 end
        for i,obs in pairs(Obs) do -- draws obsticals
          obs.x = obs.x - 3 
            sprite("Tyrian Remastered:Mine Spiked Huge",obs.x,obs.y) 
            if obs.x < -200 then table.remove(Obs,i) end
            if x >= obs.x - 75 and x < obs.x  + 75 and y >= obs.y - 75 and y < obs.y + 75 then
                sprite("Tyrian Remastered:Explosion Huge",obs.x,obs.y)
                table.remove(Obs,i)
                    lives = lives - 1
                    sound("Game Sounds One:Explode Big")
            end
        end
        for i,star in pairs(Star) do -- draws background
            star.x = star.x - 5
            sprite("Space Art:Star",star.x,star.y,star.w,star.w)
            if star.x < -200 then table.remove(Star,i) end
        end
        sprite("Space Art:UFO",x,y) -- character
            end
        if lives < 1 then -- sets condtion for lose screen
            table.remove(Obs,i)
            gS = false
            background(fade,0,0,255)
            fill(255,255,255,fade)
            fade = fade + 1
            fontSize(100)
            text("Game Over",WIDTH/2,HEIGHT/2)
            fontSize(50)
            text("Tap to try again", WIDTH/2-30,HEIGHT/5)
            text("score was "..score,WIDTH/2-30,HEIGHT/20)
        end
    end
    function touched(touch)
        if lives < 1 or gS == false then -- sets condition for restart
        if touch.state == BEGAN then gS = true  score = 0 lives = 10 
            end
            end
        if touch.state == MOVING then x = touch.x y = touch.y end
    end
    
  • edited October 2014 Posts: 300

    My submission

    Got a little help from SkyTheCoder because I couldn't get the ship to stop then you stop touching the screen.

    The collision is also a bit wonky, I need to figure out how to do round collision boxes.

    Touch the left side of screen to move ship left, right side of screen to move ship right.


    displayMode(FULLSCREEN) supportedOrientations(PORTRAIT_ANY) function setup() ast={} ship=readImage("Space Art:Red Ship") asteroid=readImage("Space Art:Asteroid Large") astFreq=1.5 astSpeed=-9 score=0 -- starting score timer=0 rectMode(CENTER) if readLocalData("HS")== nil then saveLocalData("HS", 0) end music("A Hero's Quest:Battle",true,.5) gameState=0 font("Futura-CondensedExtraBold") fontSize(64) fill(0, 255, 0, 255) shipX=WIDTH/2 shipY=HEIGHT/4 end function spawn() table.insert(ast,vec2(math.random(96,WIDTH-96),1152)) end function draw() if gameState==0 then background(0, 0, 0, 255) text("PLAY",WIDTH/2,HEIGHT/2) if CurrentTouch.state==BEGAN then if CurrentTouch.x>WIDTH/2-256 and CurrentTouch.x<WIDTH/2+256 and CurrentTouch.y>HEIGHT/2-128 and CurrentTouch.y<HEIGHT/2+128 then gameState=1 end end end if gameState==1 then background(0, 0, 0, 255) pushStyle() text("Score: "..score, WIDTH/2, HEIGHT/1.2) popStyle() for a,b in pairs(ast) do sprite(asteroid,b.x,b.y,192,256) b.y=b.y+astSpeed end timer=timer+DeltaTime if timer>astFreq then spawn() spawn() spawn() timer=0 end for a,b in pairs(ast) do if b.y<-128 then table.remove(ast,a) score=score+10 end end if CurrentTouch.x <= WIDTH / 2 and CurrentTouch.state ~= ENDED and CurrentTouch.state ~= CANCELLED then shipX=shipX-12 end if CurrentTouch.x>WIDTH/2 and CurrentTouch.state ~= ENDED and CurrentTouch.state ~= CANCELLED then shipX=shipX+12 end sprite(ship,shipX,shipY,64,96) for a,b in pairs(ast) do if b.y-96<=shipY+48 and b.y+160>=shipY-48 and b.x-96<=shipX+32 and b.x+96>=shipX-32 then gameState=2 end end if shipX-32<0 or shipX+32>WIDTH then gameState=2 end end if gameState==2 then background(0, 0, 0, 255) text("RETRY",WIDTH/2,HEIGHT/4) if score > readLocalData("HS") then saveLocalData("HS", score) end text("Score: "..score, WIDTH/2,HEIGHT/1.2) text("HighScore: "..readLocalData("HS"),WIDTH/2,HEIGHT/2) if CurrentTouch.state==BEGAN then if CurrentTouch.x>WIDTH/2-128 and CurrentTouch.x<WIDTH/2+128 and CurrentTouch.y>HEIGHT/4-64 and CurrentTouch.y<HEIGHT/4+64 then score=0 gameState=0 shipX=WIDTH/2 for i,t in pairs(ast) do ast[i]= nil end end end end end
  • Classic = class()
    function Classic:init(x)
        self.b1 = physics.body(CIRCLE, 70)
        self.b1.x = WIDTH/2
        self.b1.y = HEIGHT * .8
        self.b1.color = color(255,250,0,255)
        self.points = 0
    end
    function Classic:draw()
        background(255-self.b1.color.r, 255-self.b1.color.g, 255-self.b1.color.b)
        fill(0, 0, 0, 255)
        rect(-1,0-1,WIDTH/5 + 2, HEIGHT + 2)
        fill(127, 127, 127, 255)
        rect(WIDTH/5*2-1,0-1,WIDTH/5 + 2, HEIGHT + 2)
        fill(255, 255, 255, 255)
        rect(WIDTH/5*4-1,0-1,WIDTH/5 + 2, HEIGHT + 2)
        fill(self.b1.color)
        ellipse(self.b1.x, self.b1.y, self.b1.radius * 2)
        fill(255-self.b1.color.r, 255-self.b1.color.g, 255-self.b1.color.b)
        fontSize(40)
        text(self.points, self.b1.x, self.b1.y)
        if self.b1.y < -self.b1.radius then
            if self.points > hs then
                saveLocalData("hs", self.points)
            end
            hs = self.points
            mode = GameOver()
        end
    end
    function Classic:touched(t)
        if vec2(t.x,t.y):dist(vec2(self.b1.x, self.b1.y)) < self.b1.radius and t.state == BEGAN then
            self.b1.color.r = math.random(60,240)
            self.b1.color.g = math.random(30,240)
            self.b1.color.b = math.random(60,240)
            self.b1.y = HEIGHT * .8
            self.b1.x = WIDTH / 5 * (math.random(5) -1)+ WIDTH/10
            self.points = self.points + 1 
            self.b1.linearVelocity = vec2(0,-self.points * 10)
        end
    end
    GameOver = class()
    function GameOver:init()
        self.time = os.clock()
    end
    function GameOver:draw()
        background(255, 0, 211, 255)
        text("Tap to Play Again", WIDTH/2, HEIGHT/2)
        text("High Score: ".. readLocalData("hs"), WIDTH/2, HEIGHT*.8)
        text("Current Score: "..hs, WIDTH/2, HEIGHT*.65)   
    end
    function GameOver:touched(touch)
        if os.clock() - self.time > .2 then
        mode = Classic()
        end
    end
    function setup()
        displayMode(FULLSCREEN)
        supportedOrientations(PORTRAIT_ANY)
        hs = readLocalData("hs") or 0    
        mode = TitleScreen()
    end
    function draw()
        mode:draw()
    end
    function touched(t)
        mode:touched(t)
    end
    TitleScreen = class()
    function TitleScreen:draw()
        background(0, 255, 174, 255)
        text("[Tap to play]", WIDTH/2, HEIGHT/2)
    end
    function TitleScreen:touched(t)
        mode = Classic()
    end
    

    So here's a second entry just for the hell of it ^.^

  • edited October 2014 Posts: 342

    Using some really ugly formatting I came up with this, it could most likely be simplified to 100 lines and better formatting, but there weren't super clear formatting rules, so I didn't bother, for now.

    displayMode(FULLSCREEN)
    supportedOrientations(PORTRAIT_ANY)
    function setup()
        if not readLocalData("highscore") then saveLocalData("highscore",0) end
        boat,angle,mna,mxa,wheel,wheela,w,p,frame,physics.continuous,b,score,e,time =vec2(WIDTH/2,WIDTH/2+(HEIGHT-WIDTH)),90,0,math.pi,vec2(WIDTH/4, (HEIGHT-WIDTH)),math.pi/2,readImage("Planet Cute:Water Block"), readImage("Tyrian Remastered:Plane Boss"),0,true,{},0,{},ElapsedTime
        settween()
    end
    function draw()
        collectgarbage()
        background(40, 40, 50)
        for i=0,9 do 
        for j=0,14 do 
        sprite(w,i*100,HEIGHT-80*j) end end
        stroke(255)
        for i=#b,1,-1 do
            if b[i] and b[i].type then ellipse(b[i].x,b[i].y,10)
                if b[i].x < 0 or b[i].x > WIDTH or b[i].y < 0 or b[i].y > HEIGHT then b[i]:destroy()
                table.remove(b,i) end end end
        stroke(255,0,0)
        for i=#e,1,-1 do
            if e[i] and e[i].type then sprite("Tyrian Remastered:Evil Orb",e[i].x,e[i].y,60,60) end--ellipse(e[i].x,e[i].y,60) end
            if e[i] and e[i].type and e[i].position:dist(boat) < 45 then 
            setup()
            dall() 
            tween.stop(tr) end
            if e[i] and e[i].type and (e[i].x<-30 or e[i].x > WIDTH+30 or e[i].y < HEIGHT-WIDTH-30 or e[i].y > HEIGHT+30)  then 
            e[i]:destroy()
            table.remove(e,i) end end
        fill(255)
        text("Score: "..score.."\nHigh Score: "..readLocalData("highscore"),75,HEIGHT-20)
        noStroke()
        rect(0,0,WIDTH,HEIGHT-WIDTH)
        fill(0,0) 
        strokeWidth(5)
        ellipse(WIDTH/4,(HEIGHT-WIDTH)/2,HEIGHT-WIDTH+1)
        strokeWidth(100)
        ellipse(wheel.x,wheel.y,60)
        if tx then stroke(255,0,0,125) end
        ellipse(3*WIDTH/4,(HEIGHT-WIDTH)/2,(HEIGHT-WIDTH)/2)
        translate(boat.x,boat.y)
        rotate(angle+90)
        sprite(p,0,0,p.width/2,p.height/2)
        angle = angle + (wheela-math.pi/2)/(math.pi/2)*2
        boat = boat + vec2(2,0):rotate(math.rad(angle))
        if boat.y > HEIGHT or boat.y < HEIGHT-WIDTH or boat.x>WIDTH or boat.x < 0 then angle=angle-180 end
        if tx then frame = frame + 1
            if math.floor(frame/1)%30==0 then 
            b[#b+1]=physics.body(CIRCLE,5)
            b[#b].position,b[#b].gravityScale,b[#b].bullet=boat,0,true
            b[#b]:applyForce(vec2(100,0):rotate(math.rad(angle))) end end end
    function touched(t)
        if not tw and t.state == BEGAN and vec2(t.x,t.y):dist(wheel) < 60 then 
        tw=t end
        if tw and t.id==tw.id and t.state == MOVING then 
            wheela = math.atan2(t.y-(HEIGHT-WIDTH)/2,t.x-WIDTH/4)
            if -wheela > mxa-math.pi/2 then wheela = mxa end
            if wheela < mna then wheela = mna end
            wheel=vec2(WIDTH/4+((HEIGHT-WIDTH)/2)*math.cos(wheela),((HEIGHT-WIDTH)/2)+((HEIGHT-WIDTH)/2)*math.sin(wheela)) end
        if tw and t.state == ENDED and t.id == tw.id then 
        tw,wheela=nil,math.pi/2 
        wheel=vec2(WIDTH/4+((HEIGHT-WIDTH)/2)*math.cos(wheela),((HEIGHT-WIDTH)/2)+((HEIGHT-WIDTH)/2)*math.sin(wheela)) end
        if not tx and t.state == BEGAN and vec2(t.x,t.y):dist(vec2(3*WIDTH/4,(HEIGHT-WIDTH)/2)) < (HEIGHT-WIDTH)/2 then tx,frame = t,-1 end
        if tx and t.state ==ENDED and t.id == tx.id then tx = nil end
    end
    function collide(contact)
        if contact.state == BEGAN and ((contact.bodyA.bullet and not contact.bodyB.bullet) or (not contact.bodyA.bullet and contact.bodyB.bullet)) then 
        contact.bodyA:destroy() 
        contact.bodyB:destroy() 
        score = score + 1
        if score > readLocalData("highscore") then saveLocalData("highscore",score) end end
    end
    function settween()
        tr = tween.delay(2-(math.min(1.5*((ElapsedTime-time)/120),1.5)),function() makebody() settween() end)
    end
    function makebody()
        e[#e+1] = physics.body(CIRCLE,30)
        e[#e].position,e[#e].gravityScale=vec2(math.random(WIDTH),math.random(HEIGHT-WIDTH,HEIGHT)),0
        while e[#e].position:dist(boat) <80 do 
        e[#e].position = vec2(math.random(WIDTH),math.random(HEIGHT-WIDTH,HEIGHT)) end
        e[#e]:applyForce(vec2(300-math.random(600),300-math.random(600)))
    end
    function dall()
        for i=#b,1,-1 do
            b[i]:destroy()
            table.remove(b,i)
        end
        for i=#e,1,-1 do
            e[i]:destroy()
            table.remove(e,i)
        end
    end
    

    EDIT: I played all of your entries, and all I can say is...great job everybody!!!! :)

Sign In or Register to comment.