Into the third dimension

My loyal long-term readers (by whom I mean Anton) would know my technological aesthetic bent strongly favour the 1980s. Seeing as the third dimension was not discovered until 1992, I have thus far had little inclination to bother with it. But things have changed: now that the 90s are suitably retro I feel it's finally time to gently prod at the edges of this strange new plane...

Read on for more »

More is Zmore

Ludum Darer JellyCakes has been live streaming his playing-and-rating efforts of entries in Ludum Dare 26. He's an excellent reviewer: testing each game very thoroughly and fairly. And he's hilarious. After giving my entry a good run through its paces he concluded with the above video. Might not fit the competition's theme of "minimalism", but dang... it's awesome!

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, there was no direct pixel access of any kind! (Not counting black and white XBM images, which had been killed off by then anyway).

Eventually I was forced to get out of bed and take a look. The answer, as pictured above, was a piece of creative brilliance: each level is a simple jpg image that sits in the background. As diggers dig down they add "holes" - small black images - to the page. every few pixels dug requires a new hole image.

Destruction via creation! That's the kind of lateral thinking that'll get you places.

#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 was:

'#'+('00000'+(Math.random()*(1<<24)|0).toString(16)).slice(-6);

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)(_.plus(step)).takeWhile(!_.isAfter(to))

To use it, provide a "from" date, a "to" date and a joda time period:

val range = dateRange(
    DateTime.now().minusYears(5),
    DateTime.now(),
    Period.months(6))

Which gives you an iterator starting 5 years ago, containing every date 6 months apart, up until now. An iterator is part of scala collections - so you can toList it or map/filter etc.