It's kind of funny to think that, in a little over a month, I've tripled the number of apps I've published in the Android Market. Granted, I've moved from 1 to 3, but still, it's fun to be back in the publishing game after a few years' absence.
The latest entry is Nonsense. I wrote most of this app during an intense 8-hour-long code jam at Gravity, as part of a really cool on-site team exercise. We tend to be really heads-down on products for our clients, so this was a great exercise to get a little more creative and play around with some internal ideas. Some people paired up, but most of us played around with random app ideas we had.
I first got into programming because I wanted to make games, which is probably true for most software engineers of my age and gender. It's been years since I've spent any serious time making a game, though. Having a tight deadline like this really helped me focus and actually get something done; typically, my projects tend to grow larger and more grandiose as I develop them until it's impossible for me to complete my vision. Here, I jotted down a basic list of goals, opened Eclipse, and started typing.
The core idea behind this game was actually adapted from something I'd done over ten years earlier, on one of the last games I'd finished. "Something Strange" (also known as School Simulator 3000) was a text-based adventure, but it opened with a quirky grid of rotating letters. The overall visual effect is a bit hard to describe, but essentially, there's a random stream of letters appearing before you; gradually, particular letters stop shifting, and eventually, you realize that the frozen letters spell out a word, hidden in the larger chaos of the still-changing letters. It's a bit like one of those magic eye posters, maybe... you need to look at it in the right way to see the message.
Anyways, it was a simple idea, but one that I thought I could stretch into a game. The main graphics game together by lunchtime. I wanted to let the user highlight correct letters as they found them, so I initially experimented with having a separate TextView for each letter. I quickly realized that this slowed everything to a crawl. Fortunately, while poking around for a solution, I found that I could use a single TextView for the entire grid of letters, and use a spannable style to add color to the particular letters I wanted. Success!
The core game was easy to write. A simple Handler ticks off board rotations, which are slow at early levels and get faster later on. At each tick, every letter on the board shifts, unless it was already the right letter for the word. A click handler converts the x/y coordinate of the touch into a letter within the grid. The user loses a point or two if the letter is wrong; if it's right, a span will turn the letter red. Once all letters in the word have been identified, they move on to the next level.
While I was developing, the word was always FNORD. I knew that Android had a built-in dictionary that it uses for spell checking, but unfortunately it doesn't seem to be accessible to third-party apps; only the dictionary of user-defined words can be used, and that didn't fit my needs. Instead, I grabbed a copy of /usr/share/dict/words. I opened it in vi, and used a few global regexp replacements to wipe out everything except words containing only the lower-case letters a-z that were between five and eight characters long. That still left me with an impressive dictionary to work with, and the game would now select a random letter from that instead.
The game was working, but didn't seem like much fun yet. I spent the rest of the time tweaking it out with better mechanics and more goals and rewards. I added a set of ranks, so the player would see their status improve as they played and won. I added a lot of variations for higher levels; when a player first starts, they just see a very basic white-text-on-black screen, but over time the colors will change, letters will alter more rapidly, and at higher levels sections of the grid will freeze in place. I also added music, at which point it really started to feel like a game. I was delighted with the offerings through Creative Commons; this whole movement makes me so happy, since it lets me add professional-seeming resources to my games even without a budget.
The most important gameplay addition I made was allowing the user to guess a word before it has been fully revealed. This adds a fun tension to the game: you get double points if you guess it correctly, but lose a bunch if you guess it wrong, and don't get any bonus if it has been fully revealed. I found myself hesitating at the thought of whether to guess early, and smiled when I realized it. As Sid Meier says, any good game presents a series of interesting choices.
Nonsense was well-received by the other folks at Gravity. The following weekend, I implemented some of the suggestions I had received and some other items from my personal wishlist and made it a more commercial-ish product. Some of these were small touches that had a big impact, like adding tiny sound effects when the user clicked a letter. You get a happy "Click!" when you tap the right word, and a disappointed "Thump." when you tap the wrong one. There's a cheerful "Ding!" when the game finishes. I began to feel a little like B. F. Skinner.
I also scrubbed my dictionary; I hadn't thought of this, but it did contain some anatomically related words that could seem inappropriate, some racial terms, and other things that people might object to. I started to wish that I had a dirtier mind so I could think of all the bad words I should search for; there were way too many words for me to review them all, but I THINK I got the worst ones out. I added a feature to let you look up a word at the end of a level. Around this point, my conception of the game started to evolve... it became less about a visual trick, rewarding accurate visual perception, and more about vocabulary, being able to identify words. Now, levels started to seem more like Scrabble or a crossword. I found that I was using the "Solve" feature much more often.
I finally decided that I was reasonably happy with it; there's more I could do, but there's always more I can do, and if I've learned anything it's that I can tweak out on making a game forever. I published it out to the Android Market under the Brain & Puzzle category. It should run on every Android device running OS version 1.6 or higher. (It technically could run on earlier phones as well, but there's a weird issue where apps built for 1.5 and earlier automatically get permission to read the SD card and phone state, which worries some users of later phones.) If you have an Android phone and feel like trying something new, please check it out, and let me know what you think!