Page 1 of 1

Super small demo

Posted: Sun Apr 21, 2013 6:51 pm
by retrotails
I got bored.

Code: Select all

q=love g=q.graphics m=math function q.load()l={};t=0 end function q.update(d)t=t+d end function q.draw()for i=1,75 do x=m.sin(t+i)*64 c=128-64*(m.sin(t+i)-m.sin(t+i+1))g.setColor(c,c,c,128)g.circle('fill',x+400,i*8,8,8)g.setColor(c,c,c,128)g.circle('fill',x+398,i*8-2,4,8)l[i*2-1]=x+400 l[i*2]=i*8 end g.line(l)end
I made this for part of my picross intro and figured it could stand alone, squished into 314 bytes. It looks so intimidating, despite the simple original code (that does a few more things)

Code: Select all

    for i = 1,screen.h/8 do
        local x = math.sin(game.timer + i) * 64
        local color = 128 - 64*(math.sin(game.timer + i) - math.sin(game.timer + i + 1))
        love.graphics.setColor(color, color, color, 128)
        love.graphics.circle('fill', x + screen.w/2, i*8, 8, 8)
        love.graphics.setColor(color, color, color, 128)
        love.graphics.circle('fill', x + screen.w/2 - 2, i*8 - 2, 4, 8)
        tmp[i*2-1] = x + screen.w/2
        tmp[i*2] = i*8
    end
    love.graphics.setColor(128, 128, 192)
    love.graphics.line(tmp)
    love.graphics.setColor(255, 255, 255)
Feel free to post your own, I want to see what others can make.

Re: Super small demo

Posted: Sun Apr 21, 2013 11:24 pm
by master both
That looks so good!

Re: Super small demo

Posted: Mon Apr 22, 2013 1:11 pm
by buhb11
Nice :)

Re: Super small demo

Posted: Mon Apr 22, 2013 2:12 pm
by Robin
I managed to reduce it to 268 bytes.

For some reason, my .love is larger than yours, even though the main.lua is 46 bytes smaller. Oh well.

Re: Super small demo

Posted: Mon Apr 22, 2013 2:43 pm
by retrotails
Robin wrote:I managed to reduce it to 268 bytes.

For some reason, my .love is larger than yours, even though the main.lua is 46 bytes smaller. Oh well.
I thought about doing all that but searching for when making a global saved space seemed too time consuming. Also I wouldn't have thought to make 255 a global constant.
Anyway, this is an interesting illusion - Look at the right half and it appears to move up, look to the left and it appears to move left, and you can also see it moving up and left diagonally. It also appears to get brighter if you stare at it as a whole.
Or maybe I'm stoned and don't remember getting stoned.

Code: Select all

n=255 a=32 l=love g=l.graphics m=math function l.load()t=0 end function l.update(d)t=t+d end function l.draw()for x=0,25 do for y=0,19 do g.setColor(n,n,n,m.sin(m.mod((x+y+t*8)/8,1))*n)g.rectangle('fill',x*a,y*a,a,a)end end end
This is the best time waster at high school, it seems.
not getting stoned. i dont do drugs of any kind.
The .love is bigger then the contents - I'm on a school XP desktop right now but when I compressed my other one I was at home on Linux. Maybe this is why your .love was larger then mine, Robin.

Re: Super small demo

Posted: Tue Apr 23, 2013 3:53 am
by vitaminx
saved some characters in your boxes.love, now down to 198 bytes:

Code: Select all

n=255 a=32 t=0 l=love g=l.graphics function l.update(d)t=t+d end function l.draw()for x=0,25 do for y=0,19 do g.setColor(n,n,n,math.sin(((x+y+t*8)/8)%1)*n)g.rectangle('fill',x*a,y*a,a,a)end end end
also the zip size is smaller now, compressing with "zip -9X" on Linux results in a 266 bytes zip file.

Re: Super small demo

Posted: Tue Apr 23, 2013 5:33 am
by Santos
These are super cool! The boxes illusion is really interesting. I think I even saw it moving diagonally down and right, but like, as if it were really really fast and losing frames. I may be crazy.

Further advancements! :rofl:

Helix:

Code: Select all

q=love g=q.graphics C=g.circle S=g.setColor m=math.sin l={}t=0 h=128 f='fill'function q.draw()t=t+q.timer.getDelta()for i=1,75 do x=m(t+i)*64 c=h-x+64*m(t+i+1)S(c,c,c,h)C(f,x+400,i*8,8,8)S(c,c,c,h)C(f,x+398,i*8-2,4,8)l[i*2-1]=x+400 l[i*2]=i*8 end g.line(l)end
Boxes:

Code: Select all

n=255 a=32 t=0 l=love g=l.graphics function l.draw()t=t+l.timer.getDelta()for x=0,25 do for y=0,19 do g.setColor(n,n,n,math.sin(((x+y+t*8)/8)%1)*n)g.rectangle('fill',x*a,y*a,a,a)end end end
Here's something based on this: http://sol.gfxile.net/gp/ch02.html
image.png
image.png (35.64 KiB) Viewed 2923 times

Code: Select all

t=0 l=love g=l.graphics a=256 g.setMode(a,a)function l.draw()t=t+l.timer.getDelta()*99 for x=0,a do for y=0,a do g.setColor(0,x*x+y*y+t,99)g.point(x,y) end end end