Last month I did "Tiny Code Christmas" (#lovebytetcc), and it was lots of fun, so I decided this month to try #genuary.

The idea is simple: every day you get a prompt from this website, and do some programming art based on it.

Or not. Since I'm a few days late, I decided to begin at prompt #1, "perfect loop":

This was something I threw together rather quickly, just to get started. I used some of the ideas that I already used in #lovebytetcc, but tried to make sure that they all would loop back to zero after 8 seconds (length of pico8 standard gifs).

It could probably be done more intelligently, by restricting the time variable and making the animations based on that, but I just wanted to get something out of the door quickly.

See you tomorrow!

Second day of Genuary.

Today I went for the 6th day's (today) prompt: "steal like an artist".

I saw this really cool Genuary entry on mastodon, and I tried to replicate it in pico-8. It was fun to program it while looking at the original animation, but my code for "quarter circle" generates some really ugly quarter circles :-(. I'd appreciate any ideas for making it better (while not adding too many characters!)!

cls(7) x = 8 y = 8 a = 0.25 for z=0,0.25,0.01 do line(x,y,x+cos(a+z)*8,y+sin(a+z)*8,0) end |

Hmmm, ok, trying to answer my own question. This code will draw beautiful quarter circles. BUT it will not draw them on the top right corner... :-( I'm probably missing something very basic in my angle check condition.

cls(7) x = 8 y = 8 a = t() for x0=x-8,x+8 do for y0=y-8,y+8 do a0 = atan2(x0-x+0.5,y0-y+0.5) d0 = ((x0-x)^2+(y0-y)^2) if (d0 < 70 and (a0>a%1 and a0 < (a+0.25)%1) ) pset(x0,y0,0) end end |

A-ha, getting there!

function _draw() cls(6) x = 8 y = 8 a = t()%1 ---minimize this for x0=x-8,x+8do for y0=y-8,y+8do a0=atan2(x0-x+0.5,y0-y+0.5) if a<0.75then --urgh c=(a0>a and a0<a+0.25)and 0or 7else --urgh c=(a0>a or a0<(a+0.25)%1)and 2or 8end --urgh if((x0-x)^2+(y0-y)^2<70)pset(x0,y0,c) end end --minimize print(a%1,0,30,8) print((a+0.25)%1,0,40,8) end |

There is probably a better way than those two triple conditionals... hmmm

yay!

--- 195 chars for x0=x-8,x+8do for y0=y-8,y+8do a0=atan2(x0-x+0.5,y0-y+0.5) if a<0.75then c=(a0>a and a0<a+0.25)and 0or 7else c=(a0>a or a0<(a+0.25)%1)and 2or 8end if((x0-x)^2+(y0-y)^2<70)pset(x0,y0,c) end end --- --- 137 chars c={0,7,7,7} for x0=x-8,x+8do for y0=y-8,y+8do a0=atan2(x0-x+0.5,y0-y+0.5)if((x0-x)^2+(y0-y)^2<70)pset(x0,y0,c[flr((a0-a)*4)%4+1]) end end --- |

Well. Atan2 is slow ^^; But it works a little bit better.

Here is the cart:

[Please log in to post a comment]