December 7, 2013 · technical gaming projects

crash bang wallop what a picture

Great progress today. tl;dr - go play at http://air.github.io/encounter

1. dat.gui has bugs and nobody cares

A large chunk of today was taken up discovering and understanding a bug in dat.gui. If you feed it a variable to track - say your current X axis rotation - it’s impossible to guarantee what precision comes out on the display. So my rotation float - which only varies between zero and Pi - gets clamped to an integer, making it useless.

Turns out this is broken in the library, as reported on Google Code. Worryingly the dat.gui project seems to be abandoned. I added the patch to the issue (as figured out by someone else). Until the committers wake up again (fingers crossed) I’ll be working on a manually patched build.

2. Refactoring, always refactoring

There’s always a ton of refactoring to do, burning up time without generating anything cool. C’est la vie.

Today it was useful as it teased out my separation between things that move and are bound by pause mode (shots) and things that are mobile and can ignore pause mode (the camera, which I use for impromptu debugging once I’ve frozen everything in place). I need to make this a first-class feature.

3. Player-Obelisk collisions

This was the big milestone for today and I got there.

Again I got bitten by lack of typing in Javascript. If your function assumes that a passed object has an ‘x’ attribute, sooner or later you’re going to pass in something that doesn’t have an ‘x’ and NOBODY WILL TELL YOU. It will silently produce weird behaviour. More manual type checks needed.

I’m beginning to realise that making assumptions is a really bad idea in Javascript. For now the lesson is just to pass all parameters explicitly and don’t go digging them out of objects you know nothing about.

I was confused for ages because I was reflecting the Player (like a Shot) when they touched an Obelisk. Eventually the aha moment came, profanity was hurled and the Player now only moves, not rotates. Your ship now slides nicely past obstacles.

4. Sorting out the Camera-Player relationship

Currently the Camera sits inside the Player object, which is actually a wireframe sphere mesh. By sheer coincidence the front part of the sphere looks like a white crosshairs - a happy accident.

This gave me the idea for a 3rd person chase camera - I just need to pull the Camera back and follow the Player around at an offset.

Similarly I really like the idea of a minimap or radar that looks straight down on your ship with orthographic projection. Just add a second camera and look down on your ship, then render that in the corner. Should be useful for debugging also.

5. Achievement get

The camera is locked to the player without any ‘wobble’ in the wireframe.

The game is playable directly from github pages.

I’m using git exclusively from the command line with no crutches (i.e. the GitHub app). I even performed my first ‘git commit —amend’ and ‘git push —force origin master’ (naughty).

You can collide and slide around obelisks with a satisfyingly crunchy feeling and sound.

You can move and fly around in pause mode and check out what the shots are doing.

Comments powered by Disqus