Mr Speaker

Category: Languages

Mostly of the programming type.

DHTML Lemmings: an awesome hack

That image is the punchline to the question I awoke with in the middle of last night: “How the FLIPPIN’ ‘ECK did that guy do destructible terrain for DHTML Lemmings… in 2004?!!!”. I lay there for some time as thoughts raced through my mind: There was no canvas element in 2004. No WebGL. In fact, […]

Short function syntax is here!

It’s happened. It’s finally happened. Short function syntax is here! At least, if you’re running the nightly version of Firefox (which I am now, due to my promise to adopt the first browser to introduce short function syntax). Short function syntax replaces the lengthy function keyword with a symbol =>, and the almost-as-lengthy return keyword […]

#Random Hex colour

Want a random colour between white and black? “#” + (Math.random() * 0xffffff | 0).toString(16) That is all. [Update: after I posted this I thought… i bet this has been done a zillion times already. It was, and by Paul Irish in 2009 no less. Additionally – it doesn’t work. The best looking one there […]

Scala date range

Google it: “Scala date range”. The results are… unhelpful. The top result (a Stack Overflow link, obviously) hints at a workable solution. Here’s my implementation of it: import org.joda.time.{DateTime, Period} def dateRange(from: DateTime, to: DateTime, step: Period): Iterator[DateTime] = Iterator.iterate(from)(!_.isAfter(to)) To use it, provide a “from” date, a “to” date and a joda time period: […]

Live editing for game development

Here’s a small demo on how I’ve been using Chrome’s “live editing” features to speed up my development workflow. Chrome let’s you modify currently loaded files on the fly – so you can tweak settings and test code in real time. Don’t forget to keep an eye on the development of my up-and-coming waterski odyssey: […]

CoffeeScript: tell me how you feel about it

[update: wow, amazing response so far! I’ll start collating the data and get you all some findings soon.] Hey chaps, I’m canvasing general opinions and understanding about CoffeeScript as research for an up-n-coming book. There seems to be some pretty strong thoughts on the matter amongst the people I’ve talked to in person, and I’m […]

Colourising sprites in Canvas – part 2

And we’re back! In part one we looked at setting up a tinted palette for drawing our 8-bit masterpieces to canvas. Here’s what we’re going for today: rendering colourised sprites and tiles. We’ll be loading in the 4-color sprite sheet and rendering tiles from it with our chosen colours.

Colourising sprites in Canvas – part 1

First things first: I promise to try to limit the related posts in the future and I apologize to the legions of l337 coders for the continued coverage. Right, now, on to todays topic: “Colour like that” (Awright, punning on my own blog post titles!). While watching the livestream of Minicraft, I was intrigued by […]

_this = this

var _this = this. It always does. I write it oh-so-often to keep my JavaScript scope hanging around – and the idiom no longer makes me cringe. It’s like an old friend. The only problem with my old friend is that Textmate doesn’t have the same feelings towards him as I do. He certainly won’t […]