Saturday, September 1, 2012

Galaxy Defenders

A long time ago, in a dark room far far away, I made a small 2d shooter. The project was one of my favorite old game projects from back when I just started learning programming. More recently I did a small remake of it during a free sunday to learn some XNA.

A day with XNA

I ended up working on it some more over weekends and eventually fleshing it out into a full shooting game. Many of the mechanics were based on an old DOS game called Tyrian (whose original artist DanC writes very good game design stuff over at lostgarden). This game took on more of it's own flavor as it progressed.

The Code

The design of the game code is a very object-oriented approach. While this is very flexible for added new entities and tweaking things, structurally it is one of the worst approaches for performance. The virtual function calls and branches in object-oriented code don't let the calculations streamline very well for a system of many objects (see: TCPPBDOD).

While C# generates reasonably well optimized assembly, it's restrictions on inlining functions means that for core physics and collision objects it ends up being better to work on basic data types with minimal function calls. Vector types and helper functions are no good.

Keeping garbage objects to a minimum was more a performance issue than a memory issue, and a critical one to keep a game like this running at 60hz. I wrote about this earlier (link), so I won't repeat the details here.

The Game

The core game design based around Tyrian was reasonably fun, but not as well executed as Tyrian. The core feeling of destroying enemies and buildings in the game is key for shooting games.

Differentiating weapon types in behavior and usage was a key goal, rather than just visually different weapons. Melee weapons, shields, and high-energy-consumption alternate shot modes added a reasonably nice gameplay rhythm. The aim was to balance energy consumption and weapon usage timing to allow better skill to produce more effective results.

The UI turned out quite poor, especially the in-game shop interface. In retrospect doing more menu prototyping would have been worthwhile. Complicated user interfaces are easy, simple user interfaces are difficult.

With a lack of artists, I had to embrace programmer art and try and make it a part of the style. The game has a single color per player (ship + all weapons), two colors for enemies, and two colors for buildings. Working with these restrictions was a fun experiment in color design - having 12 stages with differing color themes that don't collide with the fixed game colors is tricky!

The first few stages are a bit slow, but things get more interesting after that as new enemies and gimmicks are introduced. It would have been better to make some more exciting early stages - the current flow has too much of a slow-start before introducing the more difficult areas.

The Music

There is a lot of free music around, but for a whole game a consistent musical theme is necessary. With this in mind, I narrowed down the most fitting tracks from rushjet1, who makes mountains amazing NES music.

I collected 15~ tracks that were of reasonable length and then tweaked the stages to the flow of the songs. I tried to theme the levels to the music where possible, I think it turned out nicely!

Code + Game + Video:

No comments:

Post a Comment