Arc Forumnew | comments | leaders | submitlogin
tetris: the killer app for arc
13 points by conanite 6032 days ago | discuss
I couldn't resist kens' challenge in http://arcfn.com/2008/05/using-opengl-with-arc.html to build tetris in arc. So it's done, using java and swing. Install rainbow as described in http://arclanguage.org/item?id=6975 , then

  java -jar rainbow.jar -f lib/rainbow/tetris.arc -e '(tetris)'
Use u,h,j,k,p and n for rotate, left, drop, right, pause/unpause and new game, respectively. Score (expt 2 n) for clearing n lines. Game size, inital delay, acceleration, colours, and key bindings are configurable in the first few lines of tetris.arc.

It fits in 206 lines, vs 303 for something almost equivalent in java. As I'm not used to thinking in lisp yet, the arc tetris can probably be compressed further. I've kept the java-swing dependencies minimal so it should be easy to port to another ui.

It's a little bit flickery and not totally bug-free, but sufficient to relive several hours of well-spent youth.

The tetris effort uncovered a couple of rainbow flaws: (sleep n) was behaving like (coma) - it slept, then recursively invoked itself. Duh. And atomic-invoke wasn't working at all, on account of the java compiler not being able to read my mind. I'll need to file a bug with Sun. Both fixed now.

enjoy!