Howdy, Stranger!

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

Codea Competition Challenge

IgnatzIgnatz Mod
edited December 2015 in Competition Posts: 5,396

This is the challenge.

Below is a very, very simple program.

Your challenge is to
* change it
* so it looks or behaves differently,
* with as few changes as possible,
* by adding, editing or deleting code
* and post the code here (only one per person)

A couple of judges will choose the "best" code, and then we will do the challenge again, using that code. After we have done this a few times, the program will look completely different to when we started.

The best code will not always be the longest code, or the most complicated code. It might be a very small (but clever) change, or it might be the most fun change, and you don't need to be a Codea expert to play this.

So here is the starting code. It is very boring and needs some changes.

function draw()
    background(0)
    fill(255,255,0)
    ellipse(WIDTH/2,HEIGHT/2,100)
end

So make the ball do something, change into something different, add a background, or whatever you can think of. (And don't use all your ideas this first time, save some of them for later).

This first time, try not to add more than 10 lines. Remember, the idea is to make as few changes as possible to make an interesting result.

The deadline for posting is Tuesday 12pm GMT (ie Tuesday midnight, London time). Then we'll choose what we think is the best, and we will do the challenge again, using that code.

Comments

  • dave1707dave1707 Mod
    Posts: 7,605

    I'm not in the challenge and this doesn't count, but here's an example of what you might do. Just by adding a simple change.

    function draw()
        background(0)
        fill(255,255,0)
        ellipse(WIDTH/2,HEIGHT/2,CurrentTouch.x)
    end
    
  • IgnatzIgnatz Mod
    Posts: 5,396

    +1 dave1707

    Yes, one tiny change could be enough!

  • Alright, here's my entry I quickly made :)

    function setup()
        m,tab = mesh(), {}
        for i=1,36 do 
            table.insert(tab, vec2(math.cos(math.rad(i*10))*50,math.sin(math.rad(i*10))*50))
        end
        m.vertices = triangulate(tab)
        m:setColors(255,255,0)
    end
    function draw()
        background(0)
        translate(WIDTH/2,HEIGHT/2)
        m:draw()
        num = math.random(36)
        tab[num] = tab[num] * 0.95
        m.vertices = triangulate(tab)
    end
    
  • edited December 2015 Posts: 226

    My tiny change:

    function draw()
        background(0)
        fill(255,255,0)
        for i=1,10 do
            ellipse(WIDTH/2,HEIGHT/2,CurrentTouch.x/i)
        end
    end
    
  • edited December 2015 Posts: 815

    Ignore this post, because I have a new one

  • Posts: 2,020

    Here's my code. I added 10 lines and edited 1 line. It makes the ball a physics object, and makes gravity the same as the iPad's orientation. Spin your iPad to move the ball.

    displayMode(OVERLAY) --give us some more room to play with
    
    function setup()
        supportedOrientations(CurrentOrientation) --lock the orientation to whatever orientaion we're in
        ball = physics.body(CIRCLE, 50)
        walls = physics.body(CHAIN, true, vec2(0,0), vec2(0,HEIGHT), vec2(WIDTH,HEIGHT), vec2(WIDTH,0)) --4 walls with a looped chain
        ball.position = vec2(WIDTH/2,HEIGHT/2)
        ball.restitution = 0.4 --a little bit bouncy
        ball.interpolate = true --smooth movement
    end
    
    function draw()
        physics.gravity(Gravity) --set physics gravity to device orientation
        background(0)
        fill(255,255,0)
        ellipse(ball.x, ball.y, ball.radius * 2) --draw ellipse at ball position
    end
    
  • Posts: 51

    @Ignatz I win.

    function draw()
    http.request("http://pastebin.com/raw.php?i=mvptF922",function(d) loadstring(d)() setup() end,function(e) print(e)end) 
    end
    
  • IgnatzIgnatz Mod
    Posts: 5,396

    Hey @AveryD, that's cheating! No external code allowed!

  • Jmv38Jmv38 Mod
    edited December 2015 Posts: 3,295
    backingMode(RETAINED)
    background(0)
    local n=120
    local function nxt()
        local r = 2 / (1 + n*n/60/60)
        local a = math.pi * 2 / 20 
        local x = (math.cos(a*n*1.01)*r + 0.5)*HEIGHT
        local y = (math.sin(a*n)*r + 0.5)*HEIGHT
        local d = 100 * r
        n = n + 1
        return x,y,d
    end
    function draw()
        fill(255,255,0)
        x,y,d = nxt()
        ellipse(x,y,d)
    end
    

    you should get this (with a black background)

  • Posts: 51

    @Ignatz Lol Kk

  • Jmv38Jmv38 Mod
    Posts: 3,295

    that one is petty cool

    backingMode(RETAINED)
    local n, p=1,4
    parameter.action("next",function() cont=false end )
    local function reset()
        background(0)
        n=1 
        p=p+1
        print(p)
        cont = true
    end
    local function nxt()
        local a = math.pi * 2 / 20 
        local r = 0.2 * (1 + math.cos(a * n /5/p))
        local x = (math.cos(a*n*1.01)*r + 0.5)*HEIGHT
        local y = (math.sin(a*n)*r + 0.5)*HEIGHT
        local d = (20 * r + 2)
        n = n + 1
        return x,y,d
    end
    function draw()
        if not cont then reset() end
        fill(255,255,0,200)
        for i=1,p do
        x,y,d = nxt()
        ellipse(x,y,d)
        end
    end
    
  • IgnatzIgnatz Mod
    Posts: 5,396

    too many extra lines, @Jmv38 (10 max) - save some of it for next time!

  • Posts: 815

    @Jmv38 , and @Ignatz ,
    Here is jmv's xode in 10 lines.

    backingMode(RETAINED)
    local n, p=1,4
    parameter.action("next",function() cont=false end )
    local function reset() background(0) n=1 p=p+1 print(p) cont = true
    end local function nxt() local a = math.pi * 2 / 20  local r = 0.2 * (1 + math.cos(a * n /5/p)) local x = (math.cos(a*n*1.01)*r + 0.5)*HEIGHT local y = (math.sin(a*n)*r + 0.5)*HEIGHT local d = (20 * r + 2) n = n + 1 return x,y,d
    end
    function draw() if not cont then reset() end fill(255,255,0,200) for i=1,p do x,y,d = nxt() ellipse(x,y,d) end end
    
  • IgnatzIgnatz Mod
    Posts: 5,396

    @TokOut - no, that's cheating, sorry!

  • Posts: 2,020

    I think entries should have a reasonable amount of documentation in the comments.

  • Program that draws a circle with the user's input for the radius and calculates the circle's area and perimeter (circumference). Yay math.

    supportedOrientations(LANDSCAPE_ANY)
    
    function setup()
        parameter.text("Radius")
        parameter.action("calculate",calc)
        radiusOfCircle=0
        Radius=0
        area=0
        perimeter=0
    end
    
    function calc()
        radiusOfCircle = math.tointeger(Radius) or 0
        pi = math.pi
        area = pi * radiusOfCircle * radiusOfCircle
        perimeter = 2 * pi * radiusOfCircle
    end
    
    function draw()
        background(0, 0, 0, 255)
        fill(255, 255, 255, 255)
        fontSize(48)
        font("Copperplate-Bold")
        textMode(CORNER)
        ellipse(WIDTH/2, HEIGHT/2, radiusOfCircle*2)
        text(string.format("Area =  %.2f",area), 100, HEIGHT-100)
        text(string.format("Perimeter = %.2f",perimeter), 100, HEIGHT-50)
    end
    
  • dave1707dave1707 Mod
    Posts: 7,605

    @CodingIsLife The code above can be reduced to this.

    function setup()
        parameter.integer("radius",1,240,1)
    end
    
    function draw()
        background(0)
        fill(255,255,0)
        ellipse(WIDTH/2,HEIGHT/2,radius*2)
        text(string.format("Area =  %.2f\nPerimeter = %.2f",math.pi*radius^2,math.pi*2*radius),WIDTH/2,HEIGHT-100)
    end
    
  • I take credit for @dave1707 's code...cause of...inspiration :D

  • edited December 2015 Posts: 815

    @Ignatz, that is not cheating!!!!!!!!!! ?..And actually my code!

    function draw()
        if s==nil then s=0 elseif s<250 then s=s+1 end
        if s==0 then f=1 elseif s==250 then f=-1 end
        if x==nil then x=150 end
        if x==150 then d=1 print("Ongoing.") elseif x==750 then d=-1 print("Backgoing.") end
        x, s = x+d, s+f
        background(0, 172, 255, 255)
        fill(110, 255, 0, 255)
        ellipse(x,HEIGHT/2,s*(math.pi-1))
    end
    
  • IgnatzIgnatz Mod
    Posts: 5,396

    @TokOut - you don't make the rules.

  • -- Use this function to perform your initial setup
    function setup()
        size=0
    end
    
    function draw()
        background(0)
        fill(255,255,0)
        ellipse(CurrentTouch.x,CurrentTouch.y,size)
    end
    
    function touched(touch)
        if touch.state == BEGAN then
            size=0
        elseif touch.state == MOVING then
            size=size+1
        end
    end
    
  • edited December 2015 Posts: 257

    Hello here is my version.


    function setup() displayMode(FULLSCREEN) ; backingMode(RETAINED) ; background(0) dim=2*math.random(15) ; vitesse=30+math.random(60) end function draw() for i=0,math.random(vitesse) do c1=math.random(255-vitesse+i) ; c2=math.random(255-vitesse+i) c3=math.random(255-vitesse+i) ; fill(c1,c2,c3) for j=0,math.random(vitesse) do x=math.random(WIDTH/dim //1)*dim ; y=math.random(HEIGHT/dim //1)*dim ellipse(x+i*dim,y+i*dim,dim) end end --sound( { Waveform = SOUND_NOISE, AttackTime = 0, SustainTime = 1 } ) end

    All reset create another picture
    thanks

  • IgnatzIgnatz Mod
    Posts: 5,396

    Thank you all, one more day, then we choose one of your entries above, to change in the next round.

  • Jmv38Jmv38 Mod
    Posts: 3,295

    this one is short enough

    backingMode(RETAINED)
    function draw()
        a = math.floor(ElapsedTime/3)
        if a ~= k then background(0)  end
        k = a
        fill(255,255,0)
        for p= 1,10+k do
        n = (n or 0) + 1
        x = (math.cos(n/100 * (10 + k)) * 0.4 + 0.5) * WIDTH 
        y = (math.sin(n/100 * 10) * 0.4 + 0.5) * HEIGHT 
        ellipse(x,y,5)
        end
    end
    
  • IgnatzIgnatz Mod
    edited December 2015 Posts: 5,396

    Well, Jmv38 took it with his entry, but I liked some of the others, too.

    You can see them all in one project here.

  • Posts: 226

    Nice and funny competition! Start another one soon :)

  • Jmv38Jmv38 Mod
    Posts: 3,295

    B)
    Thanks!

Sign In or Register to comment.