Strategic mode

Airships: Conquer the Skies
6 Jan 2014, 4:51 p.m.

Apart from individual airship fights, there is also a strategic game where you seek to unify a number of cities under your rule. Each city gives you more income and some kind of bonus: new technology like gatling guns, or advantages like reduced steel armour cost.

Like the airship combat, the strategic mode is (pausable) realtime. It's pretty simple really, it's there to give you different airship fights where the outcome matters in a wider context.

Data structures

As I did with the airships, I began by setting up some data structures for the strategic game. The most visible structure in the campaign is the game map, on which land and sea, cities, and some terrain features like forests and mountains are displayed.

In practice, the game map object contains a list of empires, which in turn contain their cities and fleets. Fleets, finally, contain airship objects - the same data structure that as used in design and combat. As in combat, all these objects have a tick() function that is invoked to move along the game.

Generating the world map

To generate the map, I used the fairly standard approach of using perlin noise, which generates pseudorandom patterns pretty well-suited to creating terrain-like shapes. A single pass of perlin noise doesn't look very good though, which is why the final map uses three noise channels with different axes, offsets and scales overlaid. Getting this part right was pretty much just an exercise in tweaking the numbers, but I'm very pleased with how it's come out. I mostly just care about which bits are land and which bits are sea, so I just apply a threshold to figure out the coastlines.

Next, cities are placed. This is pretty simple - a given map size has a certain number of cities, and they are plonked down randomly, subject only to a minimum distance to other cities - and having to be on land. Names are drawn from a list (suggestions for cool city names are very welcome) and random coats of arms are generated.

Apart from the land/sea map, the map also has (currently entirely decorative) terrain features: trees and mountain peaks. Mountain peaks are placed in (some of the places) where the perlin noise is very high (so at the actual "mountains" of the noise map). The trees are then placed according to another, mid-frequency noise map.

Displaying the world map

To display the map efficiently, I pre-render the landscape onto 256x256 pixel tiles, using edge detection to draw the coastlines. Basically, each pixel of the map is run through a function that decides whether to draw a pixel of ink. By using yet another perlin function to adjust pen thickness and jitter, I can give the map a hand-drawn feel.

Ship Management

This is what I'm working on at the moment: clicking on a city opens up a menu that lets you build a ship there. Once built, the ship joins the home fleet at that city. Fleets, in turn, can be selected and sent off to other cities, as a whole or in part. An arriving fleet then automatically merges itself into the home fleet at the destination. It's basically the same ship management interface as in Master of Orion II, which I always liked for being straightforward and not requiring the explicit creation of fleets.

Next

The next big thing is making fights happen when you arrive at a foreign city. Right now, the strategic game consists of you sitting in your single city, building ships, and sending them around with no real result!

After that, the next important thing is going to be the city defence editor, which will let you design and place defensive buildings.