March 2010
1 post
4Fourths
What a beautiful game! I got to play with this at Gamma 4 as part of their One Button showcase. It’s a co-operative game where four players control two ships using one button each: players 1 and 3 can charge and shoot their lasers, while players 2 and 4 control the upward thrust of each ship.
4Fourths
Unlike a lot of co-operative games, this one does nothing to stop players from...
September 2009
2 posts
N-Key Rollover, or Why Modern Keyboards Suck
Have you ever tried to play a two-player game on one keyboard? Chances are it wasn’t a fun experience. You press down a few keys, and the rest don’t register at all! What gives?
What we want is called n-key rollover aka NKRO, a feature that older keyboards like the IBM Model M used to have. But these days, manufacturers have been cutting costs. According to this blog, keyboard...
JavaScript Scoping Oddity
Guess the output.
var outer = "test1"
function test1(){
var inner = outer
return inner
}
function test2(){
var inner = outer
var outer = "test2"
return inner
}
test1()
test2()
August 2009
1 post
Shrinky-Fit TextArea
While working on my latest hobby project, I wanted the text entry boxes to always be just large enough for the text you’re typing into them, similar to the text boxes in desktop apps like OmniFocus.
The first solution I found, jquery.autogrow, was not satisfactory. It simply did not respond to input quick enough to avoid having text slip out of the top of my input for a moment if I hit...
June 2009
2 posts
Who says Python doesn't have function static...
If you want to store internal state in a python function, most people would say you need to create a class and use class or instance attributes. Of course you don’t. Python 3 introduces “nonlocal” as a keyword for creating static variables, but you can already make them without this help.
In fact, you might even create them accidentally, due to this weird behavior with...
Building a Good New User Experience for Elemental...
People don’t like to log in to things until they’re convinced it’s worth it. That’s a given. My first thought was to just make a sandbox mode for my game, where you can play it purely on the client side, with a friend or against the computer. If you wanted to play against other players online, you’d need to log in with an openid provider.
I showed off my new...
May 2009
3 posts
Rebuilding
I’ve lost tons of work in the past in almost every way imaginable, from melted or crushed hard disks to raid failures and unreliable hosts. I thought redundancy would save me, but these failures always seem to happen in pairs. I could fill a graveyard with all the work I’ve lost.
But I’m not gonig to let this get me down. I can still remember how I made most of those old...
Reduce by Any Other Name
One of my favorite functions is `reduce`. It’s the perfect way to represent anything like sum, product, factorial, reverse, that walks along a list accumulating the values it finds. Unfortunately, it’s hard to share my love of reduce when every language calls it something different. Observe:
# Python - reduce # reduce(function, iterable[, initializer]) def factorial(n): return...
Board Game Abstraction
How would you model a board game in a sql database? I’ve been overthinking this. I’d probably have a Game model to keep track of whose turn it is, with a lot of Pieces associated with it. But that’s obvious.
To be totally generic, a Piece could consist of string:kind, string:space, and string:color. But what if you were playing a game like chess with a 2D board? You could...
January 2009
1 post
Ruby Doesn't Have Inner Functions
Ruby syntax allows you to write something that looks a lot like an inner function in other languages. However, it really isn’t. Lets explore this odd behavior.
class Foo
def bar
x = "scoped variable"
def baz
puts x
end
end
end
This looks like a pretty standard test of closures. One might expect the bar method to define a function baz with access to bar’s...