Archive for February, 2012

Regenemies: A very simple game in Clojure

February 26th, 2012 4 comments

Lately I’ve been working on several things in Clojure with the goal of getting a better handle on general app development as opposed to library dev. Working on Seesaw and other libraries is fun and an interesting challenge in API design, but wrapping up Java interop is quite different from building a functioning app.

Anyway, one of my little experiments is a game called Regenemies. A long time ago a friend and I had the idea for “regex invaders” where regular expressions fall down the screen and you have to type in matches for them to “kill” them as fast as you can. Well, I finally got around to it this weekend. The whole falling regex thing didn’t work that well, so I opted for just showing 1 or more expressions in a grid, each with a little countdown timer to tell you how long you’ve got.

The game itself isn’t really that fun. In fact, it’s a little stressful since every missed pattern is a strike against your skills as a programmer, and therefore, your worth as a human being. But it was a useful exercise in building up the game representation and defining state transitions in a mostly functional way.

The UI, which is rudimentary in the extreme, is currently implemented in Seesaw, but I will probably give porting it to ClojureScript and canvas a try.

The game is hosted via JavaWebStart here, the code’s on github, and here’s a screenshot since people like those:

Comment and criticism welcome, especially on the game state representation. Regex generation could also use a little more love as well.

Categories: clojure Tags: ,