Can you make JavaScript’s String mutable?

Friday, February 12th, 2010

Here's a question I was pondering a couple of days ago: Can you make JavaScript's String object mutable, as in modifiable without having to re-assign the string. Why would this be useful? Sometimes you might share a string between objects, and you'd want changing it in one place get reflected in ...

Rendering graphics in JavaScript games

Thursday, January 7th, 2010

As I've been rewriting TankWar, I've been thinking of various approaches to displaying the game's graphics. At the moment, I can count three feasible approaches for rendering game graphics: DHTML - In other words, using divs with images and moving them around Canvas A hybrid: Canvas with DHTML I've considered each of these, and ...

Rewriting TankWar: Assessing the damage

Wednesday, December 16th, 2009

I have decided to rewrite TankWar, and I'll be writing a bunch of blog posts about the process. If you ever wanted to know how to write a scorched earth/worms-like game using just JavaScript, now is your chance to learn ;) This is the first one: Assessing the damage. In other ...

TankWar has online mode again: This time on Opera Unite

Wednesday, December 2nd, 2009

You may recall an earlier post about TankWar, my 100% JavaScript cannons-game. Back when I wrote it, I included online play, but the server went down with a hard disk failure. Now, I have rewritten the online mode - this time that part is also all JavaScript - continue reading to ...

Dynamic precompiling of JavaScript functions for fun and profit

Friday, November 27th, 2009

Hey it's Friday so it's time to try a fun JavaScript hack - Let's go and precompile some functions! What does "precompiling" mean? In principle, it means we take a function which takes multiple parameters and pre-define some of them. All this is done dynamically, so your code can do it ...

Using canvas to do bitmap sprite animation in JavaScript

Friday, August 21st, 2009

Have you ever thought about writing a game? If you have, you've probably wondered how to render animations for your game characters. In this post, I'll show you how you can use JavaScript to do time-based sprite animations, drawing them on canvas - vital if you want to do a ...

Unit testing JavaScript

Tuesday, August 4th, 2009

I've recently been looking into some JavaScript unit testing frameworks. There are many alternatives, and while many of them seem good, very few of them actually matched my requirements: Must be able to run tests from the commend-line Tests should be relatively easy to write

Weekend coding: Add a character counter as the background of a textarea with JavaScript

Saturday, August 1st, 2009

Have you ever filled a textarea on a page, which had a limit to how many characters you could type into it? Or maybe you are a Twitter user, and as you know, Twitter only displays 140 characters of your tweets. (Not an actual textarea) The other day I was thinking ...

Opera Command, JavaScript based Missile Command game

Tuesday, July 14th, 2009

Firstly I'd just like to let you know that the lack of posts lately is because I have a new full time job which I'm enjoying quite much so far, but it still means I have less time / motivation to write stuff. The unit testing series and other postings ...

TankWar Online, my JavaScript based cannons game

Tuesday, June 30th, 2009

Back in late 2006 I wrote my most ambitious JavaScript/game project so far: TankWar Online, which as you may guess from the name was about tanks, shooting stuff, and it had a real-time online game mode - as far as I know, the first such ever in a JS based ...