Discover moreDiscover More Services

Contract – Turn based military javascript game

by simeon on 25 November, 2010

I’ve recently been working on an oDesk contract to make a complex turn-based military strategy game for the web, the project itself is still under wraps but I can share a little about the work I’ve done so far.

The game is largely built by myself alone in Javascript and runs on pretty much anything with a web-browser including Mac, PC and iPad and is cross-browser compatible. It’s constantly tested on all platforms to ensure maximum compatibility EXCEPT I don’t test on Internet Explorer as it’s an awful browser.

The game is played by moving various types of Units around on a hex grid and each side can do things like Move, Fire, Defend, Rout, use Support amongst other things. It incorporates the usual terrain costs and line-of-site calculations that you need for a military sim.

Technology Used

The game runs almost entirely on the client in  custom written  javascript game code that’s been coded especially for this game and I’ve only used two libraries as I prefer to write my own code mainly because I can and secondly because it’s much more efficient than using bloated libraries.

The first javascript library is a vector graphic library called Raphael, which is pretty good but it has 1 fundamental problem in that it only renders to one discrete layer making it impossible to merge the graphics in through a scene. The major javascript library  I used is Prototype Javascript Framework, which I chose  initially for it’s object-orientated Class  framework but I’ve been using little bits for the DOM and the JSON / AJAX calls amongst other things. There are little bits of AJAX php on the server too. The game also incorporates Facebook login to get the users name and icon if they choose.

Along the way I tried out MooTools, which I found to be riddled with bugs and it didn’t really have the robustness needed for a game. I was tried jQuery (which I love but it’s not right for this project) for a while instead of Prototype but it’s not right for using in a game as it’s extensive feature set means that it’s quite slow, well it is in comparison to Prototype.

The game makes use of HTML5 Local Storage, CSS3 and some other little bits and bobs to make it a more rounded experience.

I find that a good understanding of how to program games is essential and you also need to be able to write tight, efficient, robust Javascript code. It reminds me of writing for the under-powered game systems of many years ago where it was equally important to get the most out of the hardware (the browser in this case).

My client is extremely happy with the work done so far and they even chose to give me a bonus for the quality and speed of my work!

Other tools used:

  • Komodo IDE – a nice little IDE for web development, if a little slow
  • MAMP – Mac Apache, MySQL & PHP local server
  • Mercurial – source distributed version control
  • Bitbucket – cloud Mercurial repository
Related tags:

Comments on this entry are closed.

Previous post:

Next post: