Base Command

Last modified: 06 Feb 2017

In this page, I briefly describe how the Base Command 3D game was developed using open source libraries and tools and with limited resources.

At the end of this page you can view some of the source code online. I only uploaded those that are relevant.

Download the game and source code here (22.7mb). Just unzip and run BaseCommand.exe under the BaseCommand\bin\Release folder.

Libraries and Tools

3D Assets

Most of the 3D assets that comes with the game are from the OGRE SDK. Sound effects that I use came from

Game Overview

The game is inspirted by the Missile Command game. But instead of missiles homing into your base, fighter jets and bombers spawn afar and would try to hit your houses - which act as your life.

Your objective is to survive as long as you can until all your houses are destroyed.

At the end of the game, players are given an option to post their high score in the leader board.

Game Initialization

To setup the scene, the following initialization functions were created and called from BaseCommand::createScene();


GUI / Game Menu

Using CEGUI to achieve my game’s simple menu requirement is sufficient enough. I created the 2 layouts manually, one for the main menu, and another for the game over menu. The main menu shows up upon game start. When all the houses are destroyed, the game over menu shows up.

I also added a community / online leader board so player can actually post their scores and see other player’s scores as well.

Game Loop

Similar to when I create the scene, I also broken the update function into smaller functions, each doing their own thing only.


Global Variables

There are global variables in the game, as the game is rather small and I’m the only one working on this, this makes my development far easier. The global variables I introduce are usually manager classes or object instances which I need to access across 2 or more files. For instance the LogManager instance where I kept a pointer to it so instead of calling LogManager::getSingletonPtr(), I can call it with just gLogMgr makes my life easier.

All the global variables are declared in the precompiled header file - stdafx.h and defined in BaseCommand.h.

Particle Effects

In order to have nice looking effects in your game, you need to have a sophisticated particle effects. The game World in Conflict by far has the best special effects I have ever seen in modern games. In order to emulate something close to the effects found in the game, there needs to be a support in animated textures/sprite.

Particle Universe offers such feature - together with other great features like plane collision (great for rain), triggers, different emitter types and so on.

In the end, your particle effects would still only look as good as the one who is creating the texture and writing the particle scripts.

Enemy AI

The game starts of spawning enemies one at a time. The spawn rate increases every minute making the game more difficult.

There are 2 types of enemies in the game:

  1. A fighter jet which flies in high altitude and fires one missile at a time.
  2. A bomber which flies in low altitude and drops consecutive bombs.

The enemy AI used steering behaviors to achieve their movements. The follow path and offset pursuit as described in the book Programming Game AI by Mat Buckland.

The offset pursuit is used when I wanted to spawn group formation flight.

For individual flights, they only use the follow path behavior.

I also make sure that the enemies does not go below a certain altitude to avoid touching the trees, as there is no collision detection between the trees and the planes, so we try not to show that penetration to the players.

C++ Classes

C++ Structures

Suggested Improvement

  1. Radar - a radar would be useful for the players so they can see approaching enemies. This can be done using OGRE’s RenderTexture class. You can define the enemies as simple red dots.
  2. Zoom - Simply change the camera’s field-of-view to achieve zoom effect. Useful when the planes are still far off for the players so they can start shooting them down.
  3. Decals - You probably want to show scorch mark on the terrain when a bullet and missile hits it.

Known Issues

  1. Sound effects will but cut half way through the game - dunno, couldn’t find the bug or what’s causing it. I was using the Sound Manager class earlier on another code but never did the sound go away.
  2. Memory leak on the grass paged geometry. The initialization is fine but when its update method is called, exiting the game will generate a memory leak. There’s a discussion about that here.
  3. Memory leak on Caelum. I update the clouds manually and didn’t went ahead with adding it to the frame listener. This seems to cause the memory leak. I also had a discussion about that here.

If anyone of you guys would be able to solve any of the known issues here, I would be grateful. Send me the patch and I’ll apply it on the source and reupload the entire package.

Thanks for reading!


Main Menu Game Over