Archive for the ‘Games’ Category

Asteroid Runner on the iPhone!

Saturday, May 18th, 2013

Earlier this week I was very happy to be able to get my Asteroid Runner game working on the iPhone with minimal fuss. It only took two tries, once using the older “iOSImpact” framework which turned out not to implement the accelerometer events, and once using the newer “Ejecta” framework. Both are made by the creator of the ImpactJS framework and basically provide a Javascript interpreter and a mock HTML5 canvas that has a rich enough API to match the way the game runs in the browser. It might be possible to use just a raw UIWebView, but after a brief foray it seems there’s a bunch of overhead around resource loading for all the images and sounds that isn’t worth re-implementing as far as I can tell.

iPhone 5 screenshot

iPhone 5 live screenshot

One of the things I’ve been happiest with through this porting process is that I built the screen width and height to be flexible early on; the game plays a little differently depending on your browser/device shape, but it avoids any kind of nasty scaling problems. Might need to move away from this for balance reasons, but during functionality testing it’s nice to see the whole spectrum on different devices (even iPhone 4 vs. iPhone 5 with their different screens).

Screen Shot 2013-05-18 at 10.10.48 PM

Relative screen heights are used throughout (with apologies for the abuse of the term ‘consts’ here)

This also required extending the ImpactJS entity class to allow positioning entities relatively instead of absolutely (since we have no idea how many pixels will be in the screen). I created a plugin that injects this into impact.entity here. I think this could be useful for other games as well that share this flexibility of scale.

Javascript Intellisense

Tuesday, May 14th, 2013

Working on my Asteroid Runner game again, and I finally found the first IDE/editor that is able to parse the ImpactJS engine effortlessly: IntelliJ IDEA!

Screen Shot 2013-05-14 at 1.48.44 PM


After trying just about everything under the sun (had previously used Coda and Komodo on this project hunting for this functionality), I had pretty much given up hope. Now I’m happy again and excited to be able to code even faster than before. It sure beats having to keep a browser window open to hunt through the API documentation for everything. The best part is that I didn’t even have to specify any paths; it did the traversal and indexing all on its own. Major points to Jetbrains for the ease of use here, although it still seemed a little too cumbersome to get the rest of the project set up in the first place.

Sound effects – clicking noises!

Sunday, February 10th, 2013

Today I spent a couple hours struggling with an annoying “clicking” noise that was showing up in my Asteroids Runner game when an asteroid got destroyed. It was somewhat sporadic and difficult to debug; early on in a game the noise was very common, and then it got less common as the session went on. How could this be?

The first thing I tried was implementing proper pre-loading of sound files, figuring that maybe there was a loading issue happening the first few times the sound played. ImpactJS handles this pretty well, letting you either load sounds at runtime (probably a bad idea), or using a sound manager to preload them:

ig.soundManager.load('media/explosion.mp3', true);
ig.soundManager.load('media/laser.mp3', true);
var deathSound = ig.soundManager.get('media/explosion.mp3');;

This seemed to smooth out the first few sound effects which was a nice gain, but it didn’t actually solve the clicking problem at all!

Next I ventured into Audacity to try to learn more about what might be causing the noise. A little experimentation with various sound effects made it clear that abruptly stopping a sound (any sudden change in volume) can lead to that clicking effect, so I went off in search of any code path that could cause sounds to get stopped early.

I made the Sound objects multi-channel so that the browser is able to play them on top of each other, theoretically preventing a case where a sound is stopped early because a new one needs to start. This seemed to improve the overall sound quality but the click was still there. I was able to tell this working by logging which channel was being used in the Javascript console:

console.log("Returned channel #" + i);

So after circling the long way around the problem trying to find the bug in my code that was causing this, I dug back into Audacity and after playing various chunks of my explosion sound over and over, I came to an embarrassing realization: the clicking sound was actually in the sound file itself. It was an artifact of the original freeware sound I had downloaded. My code, instead of causing the bug, was actually just covering up the issue in many cases!

Example of a sharp volume change that could lead to a clicking noise when played at full speed

So after another web search for publicly usable sound effects and some rewiring and damping of the new explosion sound, Asteroids Runner is click free. It now has better initial performance and smoother overall sounds to boot!


Asteroids Runner – first look

Saturday, February 2nd, 2013

After a few weeks of work, I’m finally ready to put up an early prototype of a little game I’ve been working on. It’s a vertical scroller that you control with the arrow keys and spacebar (definitely doesn’t work on a mobile device at this point). Everything is pretty rough at this point, but the basic idea is there. You can play it here:

This is an exercise in using purely Javascript and HTML5 to make a game that’s portable to most platforms. Theoretically I can package it up so that it runs as an application anywhere. The only requirement is a fairly modern browser underneath (Internet Explorer 9 or later, equivalent for Chrome/Firefox/Safari).

It’s been interesting to learn a new Javascript framework and figure out how to program into it – the low-level graphics and input code is pretty much taken care of, so I get to spend all my time drawing graphics and writing the code for the behavior of each object. That’s turning out to be quite complex, particularly getting the input and movement of the player ship just right. There’s a lot of subtlety to getting it to accelerate/decelerate exactly right depending on the keyboard input.

WordBridge – tech demo available

Tuesday, February 22nd, 2011

At long last, my game for XNA called “WordBridge” is finally in a state where I’m willing to let others play with it. It’s not much of a game at this point, since there’s only one level and no penalty for just refreshing until you get tiles you like.

Successfully crossed the river!

Still, the engine for moving tiles around and checking whether you’ve created a working bridge is now done. You can connect point A to point B, click “Finish”, and find out if you did it correctly. There may be a couple minor bugs in there, but they shouldn’t be too easy to find (let me know if you do find one).

You can download the game here (Windows only): There’s an installer in that package; I think it will prompt you to install a DirectX runtime if you don’t have one.

It’s probably possible to reverse-engineer some of the assets out of that package, so I am obliged to say that this is for individual demonstration purposes only, in case anyone nefarious is reading this.

Forcing a Decision

Tuesday, August 3rd, 2010

Some tactical discussions in our current D&D game brought to mind the debate over ending a contest quickly vs. playing optimally for the duration, one of my favorite game theory discussions.

The basic idea is that there is value in taking some risk in order to gain the chance to force your opponent to lose earlier than he normally would, even if taking this risk is not optimal play in a vacuum. That is, even if in an arbitrary game state you would be more likely to ultimately win the game by making a conservative play now than by making a risky play now, it may be in your best interest to make a risky play anyway in some actual game states.

Every post is more fun with examples, and here’s the best one I know of:

(American) Football:

It comes up every so often in football games that one team will be up by 2 points near the end of the game, and have to make a kick vs. throw* decision, deciding between 3 sure and 7 risky points. A lot of statistics have been done on whether it is better to kick or throw, and in general it depends on the yard line, the score, the amount of time remaining, and many intangible factors. In a few rare cases though, this balance can be tipped immensely in favor of ‘throw’ by the possibility of a forced decision.

For example, suppose the Aardvarks have the ball on the Badgers’ 13 yard line, and it’s 4th down and 4 to go, with 1:36 remaining in the game. The Aardvarks are winning by a score of 25-23. They have to decide whether to kick an easy 30-yard field goal for 3 points, or attempt to get at least 4 yards to keep their possession alive and ultimately score a touchdown for 7 points.

Kicking the field goal is more likely to succeed – it’s an easier play to make. It would leave the Aardvarks up 28-23 when they turn the ball over; enough that a Badgers field goal would not be enough to tie. The Badgers’ chances of answering with a winning touchdown, by marching the entire length of the field in a minute and a half, are low (much lower than the chance of them getting into field goal range and scoring 3), so this seems like the most statistically sound choice.

However, kicking in this situation is usually wrong, and here’s why: if the Aardvarks score a touchdown instead, the game ends immediately. They would gain 7 points and be up 32-23, which is a 9 point margin. It’s impossible to score more than 8 points on a single possession in football. Thus, even if the Badgers had an amazing offense that could drive the field in seconds, it wouldn’t matter; they’d have to turn the ball over to the Aardvarks’ offense after bringing the game to 32-31, at which point the Aardvarks could trivially kneel the ball to run out the clock.

This is a great example of a game state where taking the play with lower expected value (making a risky attempt to go for it on 4th down) generally actually increases your odds of winning the game. I’m not sure that it happens all that often; football creates the situation neatly because of the artificial limitation on possible points in a single possession, but maybe other games have it too.

*Yes, I am simplifying here and ignoring the option of running the football. This is because running is generally a silly option anyway. This the 21st century after all.


Wednesday, March 10th, 2010

Started playing Trine last night; very impressed. It’s a puzzle game where you have to traverse sidescroller levels using three different characters’ abilities. The graphics are very impressive and I like the art direction of the settings quite a bit. The graphic design of the ‘knight’ character could use some work though.

The first thing it reminded me of was The Lost Vikings, a similar game for the SNES that we played as kids back in the day (this was actually the only SNES game I ever played growing up, I think).


It’s good to have a nice, relaxing puzzle game to play. Now I just need to find the time…

Steam Holiday Sale

Tuesday, January 5th, 2010
Evidence of Impulse Buying

Evidence of Impulse Buying

It seems I’m not as resistant to marketing as I hoped. In my defense, they were all such great deals. This is what I picked up for about $100 over the holiday break.

Dragon Age: Origins

Tuesday, December 1st, 2009

I finished Dragon Age last night (the first playthrough of several, hopefully). It managed to be just about exactly what I expected – a successor to Baldur’s Gate in every which way possible.


If you’re a fan of “Western” CRPGs, I highly recommend it. Great story, decent mechanics, and great immersion.

I'm the guy on the left (unfortunately)

I'm the guy on the left (unfortunately)

Played through as a Dwarf Berserker on Easy – not much of a challenge, as expected. Now to start a new game as a mage who wants to rule the world on his own (even if it means dabbling in the darker side of magic).

1 vs the Firelord: A solo project

Thursday, May 21st, 2009

I’ve decided to start a new project in WoW, with the triple goals of:

1. Giving me something interesting to do in-game

2. Limiting my playtime

3. Giving me something to write about.

Here are the rules:

This guy:  tormox71 is to defeat this guy:  200px-ragnaros2

by December 31 2009.

There are only 2 rules:

1. It must be done solo – no assistance from any other player or character

2. It must be done with a maximum of 5 hours /played in any given week, Monday-Sunday.

In case you’ve not played WoW, the guy on the left is my Death Knight, currently at level 71. 9 levels to go before he caps out at level 80 – probably 2 days of play time right there, which means at least 10 weeks. After that, I’ll need to get equipment, research strategy, and practice – all inside the limit of 5 hours per week.

The guy on the right is Ragnaros, the Firelord. He’s an elemental lord capable of creating life from stone and planning on destroying the world (to which I say: get in line). At one time in WoW’s history, it took a group of 40 to take him down, and even that was not an easy task. How the mighty have fallen.