Dynamic precompiling of JavaScript functions for fun and profit

Tags:

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 on the fly. Let’s check out how this works …

Using canvas to do bitmap sprite animation in JavaScript

Tags:

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 game. You can also apply the same techniques I’ll show …

Unit testing JavaScript

Tags:

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

Opera Command, JavaScript based Missile Command game

Tags:

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 will continue (see how I didn’t say “next week”, but …

TankWar Online, my JavaScript based cannons game

Tags:

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 game. Originally the game was made for an older version …

How to pass variable values to JavaScript

Tags:

A relatively common task in today’s Web 2.0 apps is passing values from a server-side script (or through a link) to JavaScript, affecting the client-side script execution. Not surprisingly, there are a few ways to do that. Let’s look at three and their pros and cons: Embedding scripts into templates Passing variables in URLs Using configurable scripts

I wrote a Sim City clone in JavaScript

Tags:

This is why I haven’t been updating lately: I have been working on a Sim City clone, written purely in HTML, CSS and JavaScript! The game is called WidgetCity, and I’m participating with it in the Betavine Widget Competition 2009. The game was designed to run in Opera Widgets mode, but it also works in Firefox – only downside is …