Tuesday, January 1, 2013

Fast 2D Game Prototyping

I just discovered a wonderful 2D game prototyping environment called LÖVE. It is everything you need to prototype a basic game. You code in Lua and they have provided an interface to Box2D, OpenAL, and a 2D abstraction that reminds me of XNA's SpriteBatch. The back end uses OpenGL and it provides access to the pixel shaders if you want to get fancy. Probably the most impressive thing about it from a technical standpoint is that they support multiple threads in Lua, which only supports coroutines natively. For the curious, it accomplishes this by giving each thread its own isolated Lua environment, but creates a message queue that they both can access.

I spent some downtime this break prototyping some ideas I have had for a hexagon based puzzler. It feels great to get into the game design part so quickly and not have to worry too much about the engine. The hardest part about it was getting used to not having integer math. (Lua is floating point only.) For example, to find out if an integer is odd, you can do x & 1. In floating point, you have to use something like x % 2 >= 1. (Note: this method is the equivalent of rounding down to the nearest integer.) Overall, though, it is nice to just kick back and let the code flow. I highly recommend LÖVE.