Building airships

Airships: Conquer the Skies
2 Oct 2013, 9:45 p.m.

Since the last installment, I've been mostly concentrating on improving the editor and the ship visuals, including windows, an outside view mode for editing armour, and even smoke.


One of the first things I did was write some code to calculate various stats about the ship: its weight, the lift capacity of its suspendium chambers, its speed, etc.

As part of that, I refactored the ModuleType class a bit using a Builder - Java's workaround for the lack of named parameters with default values. Lots of boilerplate code, but at least module types are less unreadable now.

Prettier graphics and animation

I also improved the graphics in a bunch of ways, by adding animation frames for the propeller and suspendium chambers, and by having the weapons stick out beyond their grid a bit. I also added versions of the various armour types with windows, and specified where those windows go with each module type.

This works especially well now you can see the airship from the outside: instead of a featureless block, it now has windows you can see the inside through, and weapons sticking out.

I also added a simple particle system so that the steam engines could emit steam.


Next, to improve the way the airships look, I decided that the edges should be lit. This involved writing some code to figure out the adjacency of tiles, and some more code for drawing translucent rectangles on the basis of that information. I think the result is quite pretty, but the code's a bit, er, long. Oh well, it works.


Given that this is meant to be a game about airships fighting, it would make a lot of sense if they were able to face in opposite directions. This required some careful abstractions about what which parts of the code thought of as "positive x", but by being methodical, I managed to make it work with not too much swearing.


This has been quite a few hours more work, quite a lot spent debugging and fiddling with lighting code, and feeling a bit embarrassed about getting the math wrong. Still, I'm pretty pleased with the result: you can now make airships, and they look quite nice.


With airship creation more or less done, the next step will be animating them: adding state to modules, adding crew, creating a job queue for modules to request things from the crew. Once that's done, it should be possible to hit "play" and have the little airsailors run around, fetching things.