Work Starts on my WebGL Game!

Caught up in all the excitement of WebGL becoming more mainstream, I’m building another javascript game. My first offering to the browser based game community was Manic Spaceman, a straight platform game based on ManicMiner which was a little rough around the edges, but boshed out on the quick for the 8weekgame competition.

This time round I intend to go full 3d, taking advantage of WebGL, and make a desert strike style game. I considered starting from scratch, as I did with Manic Spaceman, and writing my own engine to power it all, however given that I’ve next to no 3d experience I thought I would reduce the scope a little and use an engine that’s already out there. After about a week of research I’ve settled for Three.js – I say “settled”, but it’s actually shaping up to be a pretty awesome engine. There’s are a few decent engines out there, all obviously in their infancy, but having reviewed the feature set and looked at the demo’s and read around other developers experiences,  Three feels like the best choice. The other’s I considered were;

The Short List

Other contenders

I only considered open source offerings and looked for engines which

  • were still being actively developed (!)
  • seemed performant with high poly counts
  • handle shadows/ reflections
  • exposed access to GLSL
  • UV Mapping support
  • be relatively stable.

It was surprising how many engines had broken demo’s on their site, which never bodes well, but on the whole, they are all good offerings with almost all of them fulfilling my requirements.

While building my game, I shall be working through some OpenGL tutorials I found- a port of the well known NeHe OpenGL tutorial set, on LearningWebGL.com, which should put me in good stead to build my next game totally from scratch.

I shall post updates as I have something to show.  So far I’ve written a HeightMap generator which works from a greyscale bitmap to build terrains, and I’m currently working on getting the model to follow the landscape; I’ve a long road ahead!

3 Comments

Random Band Generator!

Just a quick post to mention that I’ve uploaded the Random Band Generator- just a bit of fun I boshed together built for a mate… check it out here.

No Comments

ManicSpaceMan now works in IE(9)!

Cast your mind back to about 6 months ago when Gareth, Martin and myself did the first 8WeekGame competition- Controversially I didn’t use XNA, but instead created a game which would run from your browser, using the new HTML5 canvas support- at the time it was a niche feature without wide browser support, but with the recent release of IE9, you can now finally play ManicSpaceman in IE! So go upgrade your browser and give it a go! Although I should note– for some reason the sounds don’t play in IE, despite me creating a whole MP3 set of the sounds specifically for it; so the best experience is still in FireFox or Chrome!

While on the subject of IE9- see here for the terribly useful developer notes on the new browser detailing all the new cool stuff it supports (css3/ html5 features) http://msdn.microsoft.com/en-us/ie/ff468705#_Intro

2 Comments

Finally, proper browser support for WebGL thanks to Google Chrome!

Google released Google Chrome v9 a few days ago with native WebGL support- no more having to hack around hidden browser settings, WebGL will now work, out of the box, on one of the “main stream” browsers.

In light of this I’m doing a round up a bunch of WebGL 3d engines available at the moment (which I shall put up here when I’m done) to help me select which engine to use as the base for my next 8weekgame competition entry. I think I shall stick with the re-make of Desert Strike, but will be moving away from the original XNA I started out with, to make it totally web based (No flash plugins!) like my previous submission, Manic Spaceman

No Comments

Microsoft Creators Club – Premium Account Cancellation- Microsofts best kept secret!

So I signed up for an Microsoft creators club account a while back and it just auto-renewed. I’ve not used it for a while so figured I would cancel it from robbing me of any more money! I hopped over to their site at https://windowsphone.create.msdn.com/support and after an hour of hunting through EVERY part of that site, and various forums posts with other people complaining of the same thing which pointed me to a bunch of “Account Cancellation” links which all ended in “Oops, this page has been moved!”. I was even directed to billing.microsoft.com which acknowledged the fact that I had this £30 payment going out every 4 months; I clicked on the row and then clicked to disable the service, which brings up a bunch of links to various websites, but nothing about the creators club!? So, the site basically told me what I already knew, and did nothing to help solve the problem.

I eventually came across a forum post which pointed me in the direction of a contact form: https://windowsphone.create.msdn.com/support?redirectToUrl=%2FApp. Upon completing the forum I was redirected to the app creator home page- no “thank you, we will get back to you” page, so now I can only wait and hope that someone actually picks up my mail!

2 Comments

JQuery Validate() method for JQueryUI AutoComplete drop down boxes, while using KnockoutJS

It seems to be a rare mix, but on my form I have fields which are bound at client side using KnockoutJS, in drop downs styled using jQueryUI, using the expirmental autoComplete variant, which I then want to validate using jquery Validate method, to ensure someone actually selects something from the drop down!

So my form field looks like this;

<select data-bind='options: lookUps.Titles, optionsCaption: "Select...", value: Title, uniqueName: true'></select>

I have the following javascript to add the combobox autocomplete functionality;

 $("select").combobox({
                selected: function (event, ui) {
                    $(ui.item.parentNode).change();
                }
            });

Again, you’ll notice there’s another hack here to make everything play together nicly (see my blog post here)

Finally, the validation fix;

$.validator.addMethod('selectValueSelected',
          function(value, element) {
              return this.optional(element) ||
                (value.indexOf("__ko.bindingHandlers.options.optionValueDomData__") == -1);
          }, "Please select an option");
        $.validator.addClassRules("mustPopulateDropdown", {
            selectValueSelected: true
        });

All you need do now is add the css class “mustPopulateDropdown” to your select tags and they will be validated.

No Comments

KnockoutJS won’t bind to fields with numbers at the end?

Maybe this is just me? Almost finished my Sales Entry form I’ve been tinkering with- adding a “Create Customer” dialogue, and every field bound as it should (using Knockout) except for 3; Address1, Address2 and Address3. The moment I changed Address1 to AddressHouseNumber, it started working- so i changed the other, and sure enough they all started working. I tripple checked for typo’s so it wasn’t that- the input fields looked like this;

<input data-bind="value: Address1, uniqueName: true" class=""/>
<input data-bind="value: Address2, uniqueName: true" class=""/>
<input data-bind="value: Address3, uniqueName: true" class=""/>

Weird! has any one else come across something like this?

2 Comments

More Manic Spaceman (8weekgame) documentation done

I promised I would, and I’m finally getting round to documenting the rest of the classes I wrote for my javascript platformer I built for the 8weekgame competition, as well as putting up the sourcecode. There’s still a few more to do, which I shall bash out through the course of the rest of the week. Check them out at www.shawson.co.uk/codeblog/8-week-game-competition/

No Comments

KnockoutJS/ jQuery tmpl with jQuery Validate

Quick post; I found tonight that my jquery validate was letting my knockoutjs viewModel.save() method run, even if the form wasn’t valid. This turned out to be because you need to set “uniqueName: true” on any form fields you want validated. Eg

<input data-bind="value: ChargedShipping, uniqueName: true" class="required number"/>

1 Comment

Unit testing Javascript event handlers or any other asynchronous delegate calls using jsUnit

I had to nock up a test for a simple method I had added to a connection manager class. The class tracks wether the client browser has a current connection to the server, and the method I added was simple “check connection” which wrapped prototypejs Ajax.Request method; you basically call the method with a filename and a success and failure call back. I wanted to confirm that, given an accessible filename, the checker would call the passed delegate for success and set a few flags internal to the class.

We needed to make sure the Ajax.Request had totally completed and the result was ready to be tested before the jsUnit test was executed, which meant some how imposing a delay which coudl be cleared once one of the callbacks had fired.

The solution was simple; add a setUpPage function to the page which is a reserved function name which the jsUnit framework looks for. If this function exists it will hold off executing the tests until the setUpPageStatus variable is set to ‘complete’.

My final test for the success case looked something like this;

status = '';

function setUpPage() {
	myConnectionStatus = new ConnectionStatus();
	myConnectionStatus.checkConnection(
		"test.txt",
		function() { // success callback
			status = 'success called';
			setUpPageStatus = 'complete';
		},
		function() { // failure callback
			status = 'failure called';
			setUpPageStatus = 'complete';
		}
	);
}

function test_CheckConnectionCnxOK() {
	assertEquals('The success handler should have been called', 'success called', status);
	assertTrue('Connection should be set to online', myConnectionStatus.isOnLine());
}

1 Comment