useless code

Here’s some useless code that someone might find interesting. Wrote it last night while watching Thursday Night Football.


displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)

function setup()
    physics.continuous=true
    fontSize(25)
    tab={}
    e1=physics.body(EDGE,vec2(0,2),vec2(WIDTH,0))
    e2=physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT))
    e3=physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT))
    e4=physics.body(EDGE,vec2(0,HEIGHT),vec2(WIDTH,HEIGHT))
    str=" dave 1707 "..os.date().." dave 1707 "..os.date().." dave 1707 "
    s=1
    s1=0
    c=5
    while s1~=nil do
        s1,en=string.find(str," ",s)
        if s1~=nil then
            str1=string.sub(str,s,s1-1)
            s=en+1
            w,h=textSize(str1)
            c=c+w+7
            a=physics.body(POLYGON,vec2(-w/2,h/2),vec2(-w/2,-h/2),
                    vec2(w/2,-h/2),vec2(w/2,h/2))
            a.x=c
            a.y=HEIGHT-20
            a.restitution=1.12
            a.gravityScale=.2
            a.info=str1
            table.insert(tab,a)
        end
    end
end

function draw()
    background(0)
    for a,b in pairs(tab) do
        fill(255)
        pushMatrix()
        translate(b.x,b.y)
        rotate(b.angle)
        if b.info=="dave" or b.info=="1707" then
            fill(255,0,0)
        end
        text(b.info,0,0)
        popMatrix()
    end
end

Here’s a different version of the above code.


displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)

function setup()
    physics.continuous=true
    fontSize(25)
    tab={}
    e1=physics.body(EDGE,vec2(0,2),vec2(WIDTH,0))
    e2=physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT))
    e3=physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT))
    e4=physics.body(EDGE,vec2(0,HEIGHT),vec2(WIDTH,HEIGHT))
    str="dave1707"..os.date().."dave1707"..os.date().."dave1707"
    c=5
    for z=1,string.len(str) do
        str1=string.sub(str,z,z)
        w,h=textSize(str1)
        c=c+w
        a=physics.body(POLYGON,vec2(-w/2,h/2),vec2(-w/2,-h/2),
                vec2(w/2,-h/2),vec2(w/2,h/2))
        a.x=c
        a.y=HEIGHT-20
        a.restitution=1.12
        a.gravityScale=.2
        a.info=str1
        table.insert(tab,a)
    end
end

function draw()
    background(0)
    for a,b in pairs(tab) do
        fill(255)
        pushMatrix()
        translate(b.x,b.y)
        rotate(b.angle)
        text(b.info,0,0)
        popMatrix()
    end
end

@dave1707 Thats cool. It could be used to make a pretty boss credits screen.