Mr Speaker

Category: Javascript

The best kind of script

DIY Old-school racing game: Part 1

Remember Pole Position? Outrun? PowerDrift? Lotus Esprit Turbo Challenge? Yeah you do! Remember jQuery 1.4? Most likely! Let’s combine those two memories into one DIY project and make our very own old-school racing game with jQuery 1.4, shall we? To prove it could work, here’s an early proof-of-concept to hopefully pique your interest. It’ll take […]

Parcycle: A Particle System with HTML5 canvas

All this PPK “iPhone developers are stupid” awesomeness got me thinking. Now, if there’s one guy I’ve got respect for, it’s PPK. And if he tells me to ditch objective-c for JavaScript, then I’m damn well going to do it. Accordingly, I decide to create “Parcycle”: a Particle Emitter system that I re-wrote from a […]

JavaScript iPhone Games: Part II

Interesting JavaScript times abound! Recently the Pie Guy JavaScript iPhone game has provided a sneak-peek at what we can do with the awesome one-two punch of ECMAScript and the iPhone. Accordingly, I went back and applied some pie-guy tricks to my platformer…

Selecting JavaScript objects with jQuery

After a bit of prodding around I’ve not only found out that selecting JavaScript objects and arrays with jQuery is fully supported, but there are also some potential use cases! It all started a couple of weeks ago when I thought it would be cool to bind custom events to actual JavaScript objects.

Closures with self-invoking functions

Just a quick note-to-self… I’m a big fan of using self-invoking anonymous functions to keep stuff out of the global namespace, but I forgot that they are also nifty for keeping variables in scope via closures. Here’s the problem… Let’s say with have an array that we’d like to populate with functions. The functions simply […]

Using jQuery on JavaScript objects (Part 1)

Today I was trying to decouple some JavaScript classes in a game prototype I’ve been working on. I didn’t want to get into implementing some kind of interface behaviour, and so I thought about a simple Observer pattern. There are a bunch of solutions around the tubes (and indeed I’ll probably use one of them) […]

Smoking Canvas

On the way to work today I remembered an old trick to create a “fire” effect: you randomly assign a colour to the pixels on the bottom row of the screen (in the same hue) and for each row above it take the average of the 3 pixels immediately below it, and 1 pixel that […]

Springs with Canvas

Even more Canvas vs Maths fun! This JavaScript demo vaguely emulates some spring physics. There are 10 linked points – each of whose acceleration is determined by the distance to the spring in front of them. A nice curve drawn between each point using the quadraticCurveTo command. And it sure makes some perdy patterns. The […]