Chain Factor JS

Chain Factor JS

Download Chain Factor JS (10 KB)
Download jQuery 1.2.3 (94 KB)
Download all code in zip file (97 KB)

Chain Factor is a great little puzzle game that I like to play once in a while to clear my head if I’m working on a tough problem, or just when I’m bored. It’s pretty simple: click on a column in the board to drop the next ball into that column. When the number on a ball matches the number of consecutive balls in the row or column that ball is in, the ball will clear. The FAQ on the Chain Factor site probably explains it better than I can.

I was bored one afternoon and wanted to play Chain Factor, but I only had my iPhone, which doesn’t handle Flash. So I did what any reasonable web developer would do and cloned it in Javascript. This is NOT a full game; I started with the goal of playing it on my iPhone, but soon decided that I just wanted to see how simple I could make the basic game play.

Chain Factor JS was written with jQuery, and almost the entire game relies on the DOM. Aside from a couple configuration variables (how big should the board be, etc), only two variables about the game are stored: what will the next ball be, and whether or not the previous move is still being processed. When you drop a ball, the DOM is polled to determine which balls need to be cleared, and which ones then need to be shifted down. Is this the most efficient way to do it? Almost definitely not, but I wanted to get more comfortable with jQuery and see how simple I could keep my Javascript. The code could be shorter, but I’ve always been of the opinion that readability is preferable to brevity.

This version doesn’t keep score, and it doesn’t add the gray balls that make Chain Factor interesting, but I think it’s still fun to play with. Even as I’m typing this description, I keep stopping to play with it for a bit.

Share


About

BrockMy name is Brock.

I am a web developer, an atheist, a DC resident, and a bit of a movie enthusiast. I try to write about those topics at least now and again, but this site is mostly just a bunch of crap about my life.

I grew up outside Buffalo, NY, and went to RIT. In November 2005, I moved to the Washington, DC metro area. For the most part, it’s been pretty good to me.  These days, I live a couple blocks from Chinatown in DC with my lovely wife Erin and our Bichon, Lola May, and work for a PR firm downtown.

You can contact me by e-mail at brock@brockboland.com.

Elsewhere

Share

Categories