Mr Speaker

mrspeaker's head in a monitor You find yourself at the entrance to the Hompage of Mr Speaker. In a darkened corner sits a trunk containing HTML5 games and some JavaScript tidbits. Next to it you spy a mastodon account. Exits are North, East, and .

Three.js: looking away from .lookAt

Have a hankering to look in the opposite direction of the vector you get from Three.js's .lookAt function? You need .lookAwayFrom! Dunno if there's an easier way, but the idea is find the vector between the target you'd normally "look at" and you, then add the resultant to your current position, and look at that instead! Here's the standalone function:

function lookAwayFrom(me, target) {
    var v = new THREE.Vector3();
    v.subVectors(me.position, target.position).add(me.position);
    me.lookAt(v);
}

To face away from an enemy, you might do something like lookAwayFrom(player, enemy) and away you scarper. If you want to integrate it into Three.js, so you can do player.lookAwayFrom(enemy) then here ya go:

lookAwayFrom: function(target) {
	var v = new THREE.Vector3();
	v.subVectors(this.position, target.position).add(this.position);
	this.lookAt(v);
}

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.

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: WaterSki or Die! (coming to a phone near you soon, with programmer art removed).

Track: Fuck me dead

Just found this weird ol' track I made a few years ago. Like all my weird ol' tracks, it was never finished. Now it's finished.

‘mazed

Maze generation has never been easier:

Math.random() < 0.5 ? "/" : "\\";

and you've got yourself a maze! Like all awesome ideas this one comes directly from the Commodore 64.

A better phonetic alphabet

I found this in a txt document that myself & the missus wrote, possibly when drunk, in 2002. Seems important.

Aquaman
Barometer
Chicken
Dress-ups
Eatery
Fedora
Goal Posts
Heliotrope
Irksome
Jalepeno
Kraftwerk
Limp
Moisten
Nice
Oblong
Pancake
Quincy
Restrooms
Satay
Tanktop
Uppity
Voltimeter
Wafting
Xtreme
Yurt
ZZ Top

What you’re missing out on on App.Net

Maybe you've heard that there's a new kid on the short-message scene: App.Net. It's just like Twitter, except you have to pay $50 a year to use it. Sure, that'll keep the poor people away - but what else do you get for the fee? How's this for an incentive: no longer are you limited to the measly 140-character messages tyrannically enforced by Twitter!

You get 256 characters.

For the people who don't need to save their $50 for food and rent and medicine and stuff that's a big 116 extra characters to flaunt! Accordingly, I've created an app to periodically fetch and highlight these extra characters - so the regular folk can see what they're missing out on. I call it...

Read on for more »

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 curious to know what others think.

If you know any web devs/designers/anyone making web things then please send them here, or - if the scrolling iframe is breaking your brain - directly to the "CoffeeScript, and you" survey (It's a google form thingo - if that doesn't work for you, just give me some free-form rambling in the comments!).

Thank you kindly!

Read on for more »

Nicer random colours, with HSL

As many of you may know from my complaining, I've currently embarked on a new writing mission: a CoffeeScript book for SitePoint. The example project that runs throughout is an HTML5 game using Canvas. While I was trying to create a random colour palette - for instructional purposes - I fell over this "trick" of using HSL rather than RGB to pick more pleasant-ish colours.

Read on for more »