Watch and be amazed :)
It was really fun to optimize the code to its limit.
You can just paste this in pico-8.
here is the code:(space is only included in this post)
i=line::h::n=t()/3x=cos(n)*40y=sin(n)*40q=128p=63u=-abs(x)/10for z=0,3do j=z%2*q k=z\2*q i(j,k,x+p,y+p,u)i(j,k,p-x,p-y,u-1)i(j,k,p-x,y+p,u)i(j,k,x+p,p-y,u-1)end for i=1,999do pset(rnd(q),rnd(q),0)end flip()goto h |
Im not sure if I can compress it any further, but if you
see anything please comment it.
P#129444 2023-05-06 14:58 ( Edited 2023-05-07 15:16)
Really nice!
I think this cuts about 40 characters off the minified code:
i=line::h::n=t()/3x=cos(n)*40y=sin(n)*40q=128p=63u=-abs(x)/10for z=0,3do j=z%2*q k=z\2*q i(j,k,x+p,y+p,u)i(j,k,p-x,p-y,u-1)i(j,k,p-x,y+p,u)i(j,k,x+p,p-y,u-1)end for i=1,999do pset(rnd(q),rnd(q),0)end flip()goto h |
A few things I did:
- Combined for loops
- Changed how time was tracked (kept time scale about the same though)
- Inlined or got rid of unnecessary constants and computations -
l
could be replaced with unary negation,o
was only used once and so took fewer chars to inline, etc. - After doing the above, rearranged some things to require less whitespace
I think it's very likely more could be done: I probably missed some things, and I haven't really tried to understand the code in a way that would enable deep changes.
P#129447 2023-05-06 16:22 ( Edited 2023-05-06 16:29)
hey, this is pretty cool!
plus luchaks's code is so small that it maybe will work
P#129469 2023-05-07 14:08 ( Edited 2023-05-07 14:09)
[Please log in to post a comment]