This past couple weeks I’ve been busily working on architecting many little things (super important things) for my new game. One of the big things I really didn’t set out to do initially, but once I realized my efforts were converging there, I decided to make it a priority: Live Coding.
I am using a scripting language Squirrel to handle the gameplay side of the programming. This is new for me, having hardcoded or written my own sub-par scripting and data entry dialects to make my prior games.
I opted for Squirrel over LUA due to its similarities to C and C++. It’s created by a fellow gamedev, so issues we have with the LUAs of the world are taken in to serious consideration. It counts from zero (!!), uses C/C++ style comments, has an integer type, uses float instead of double, uses reference counting instead of a GC, and most importantly: uses a file extension “.nut”… LET THE TOTALLY SILLY LATE NIGHT CODER JOKES BEGIN!
Performance benchmarks of Squirrel 3.0 place it on-par with the non-JIT LUAs. There’s a well known scripting benchmark that shows Squirrel doing poorly (Version 2.2), but a friend did his own benchmarking recently that shows things have dramatically improved. Another dev informed me that LUAs JITs are now available on ARM and PPC, and at least the ARM benchmarks are a huge improvement (PPC not so much). Apple still has their execution policy in place, making a JIT useless, but that aside I value my own sanity and prefer not-to have to switch my brain in to coding thinking too far away from my comfy C/C++, and admit there are elegance improvements to be made over that (I see working in Squirrel to be a potential improvement… maybe!).
On Live Coding again, I see it as more than just code. Right now it’s only script code, but very soon I plan to extend this to other forms of game content (textures, models, shaders, maps, etc).
My Live Coding setup is bound to the Window focus. When the game re-gains focus, a process of scanning content begins, and any assets found to have changed are reloaded. Pictures:
Script before modification. Showing a no-change refresh. Currently just text printing that AWESOME line.
An ALT+TAB, some munging with the Main.nut script file, an ALT+TAB back in:
After modification, things go from AWESOME to SILLY. Tom is an instrument.
Assuming there were no errors, script is recompiled and executed, so that it re-overloads the referenced functions.
I’ve given myself a relatively short timeline on this game, considering what I want from it, and considering all the distractions I have in the coming weeks (I am moving early September). I want something playable by IGF Submission time (October 17th), though I’m undecided if I am entering (unlikely far enough). I want it VERY playable for GDC (March 2012). I want to be shipping on the first platforms late Summer 2012, so roughly a 1 year timeline. Being able to SUPER-RAPIDLY do and test something in game is VITALLY important if I’m going to make it.
Currently the Live Code system is set up for Squirrel scripts, the language all gameplay code will be written in. Next up I need to add support for Shaders, Textures, and 3D models. Search paths are already set-up to pull files from the source folders first (unless a release build, then native/optimized content gets loaded first).
Next weekend is Ludum Dare, so I have a little bit of work to do there in the near term. I am hoping to have several forms of Live Code-able content ready to be used before we begin the event. Fun fun.