Some data structures

Airships: Conquer the Skies
1 Oct 2013, 10 a.m.

Having set up the project, I started on the basic data structures for holding information about an airship.

Each Airship consists of a number of Modules arranged in a grid. These modules range in size from 1x1 for a corridor to 4x2 for a heavy cannon. Each grid tile also has a piece of armour plating that can be wood or steel and light/medium/heavy. On the basis of this, I created a bunch of classes to represent these concepts - airships, modules, armour plates, types of things, as well as shots and tiles.

Module and armour types are currently just enums - I might make them data-driven at some point, but for a prototype, this is easier. Nor did I create a hierarchy of types, which does unfortunately mean that there's quite a lot of constructor arguments. Again, this is fixable when it becomes necessary.

Rachel was helping me with some of the typing and also was very helpful in discussing what numbers to make up. We settled on there being two types of damage: blast and penetrating. Steel armour is better against the former, wooden armour better against the latter - though steel is all-around stronger, of course.

Finally, I started stubbing out some methods on the Airship class. Right now, it doesn't have any fields, because I haven't totally settled on how to do the internal data structures. (Are modules in a list or in a 2D array?) But that's what encapsulation is for.

I also decided that the graphics are going to be sort of pixel-art-ish, and that each grid tile would be 16x16 pixels. So we created an "Appearance" class that represents a rectangular area on the spritesheet in multiples of 16 and also takes care of simple looping animation for when I want it.

Next up: drawing the basic graphics.

Oh, also, if you want to follow this series in particular, here's a handy RSS feed.