Tempest-cljs in Mozilla DemoStudio

related: tempest , clojurescript , clojure , html5 , games

I submitted the current form of Tempest-cljs to Mozilla DemoStudio:

Tempest-cljs @ Mozilla DemoStudio

Of course, it’s always still available on GitHub.

It has been under casual, constant development for about the last month.  Since the last post on the subject, it really changed from a ClojureScript demo to an actual game.  Just changing the colors to match the original did a lot, psychologically, but it’s also full of new features.

Over the past day I have been focusing on performance a little bit.  Performance has been all over the place, depending on the browser and the level and what enemies are currently alive.  I ended up writing a few benchmarking demos to use along with Chrome’s Javascript profiler to get a sense for what’s slowing it down.

I’ve mostly been replacing frequently-calculated values, like the cartesian coordinates of all the points on a level, with cached copies.  Since the game started off as just a demo of line drawing, there are still a lot of values in there that are calculated every frame, despite never changing.

The biggest performance surprise, so far, has been the dramatic increase in performance gained by using Clojure’s map destructuring in the argument list, instead of manually pulling out the keys I want in a let block. 

There was also a dramatic speed increase, for some things, by turning on Google Closure’s advanced compilation flag.  I believe it does code-inlining, and my guess is that’s where the increase is coming from.  All told, in the past 12 hours the projectile benchmark has gone from 6 FPS average to 26 FPS average on my MacBook Pro.