Metric Panda Games

One pixel at a time.

Extracting The Engine

Rival Fortress Update #29

Engine work for Rival Fortress is coming coming to a close. This weekend I decided to give it a test run with a simple prototype in order to get a feel how the API was shaping out.

While I was at it I also extracted the engine into a separate Git repository by using Git subtrees.

Git Subtrees

Git subtrees are a simple way to both split a subdirectory of an existing repository into a separate repository and include an external repository within your main repository.

I use subtrees to extract reusable components into libraries from projects I’m working on. In Rival Fortress’s case, the directory tree was structured like so:

   - engine
     - game
     - platform
     - generated
     - libs
   - game
     - libs

As you can see all engine code is contained in the engine subdirectory, so it was easy to pull out into a separate repository while keeping all commit history relative to the subdirectory.

You can find an excellent introduction to subtrees, with its Pros and Cons, in Atlassian’s blog post The power of Git subtree, as well as the official man page.

Convention over configuration

I’m a big fan of convention over configuration, and this is reflected by the way I structure engine and game code.

The engine expects certain files to be named in a specific way, as well as the folder structure to follow the one outlined above. I find that this makes it easy to bootstrap projects as well as giving the user of the engine/framework smarter defaults.