Base Command10 Jan 2009
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 Graphics Engine - OGRE 3D v1.6.1 http://www.ogre3d.org
- Terrain Editor - ArtifaxTerra 3D http://www.artifexterra3d.com
- Particle Effects - Particle Universe v1.0, OGRE plugin http://www.fxpression.com
- Clouds rendering - Caelum v0.4, OGRE plugin
- Foliage - Paged Geometry v1.05, OGRE plugin
- Terrain engine - ETM v2.3.1, OGRE plugin
- Sounds - FMOD and SoundManager class from the OGRE wiki http://www.ogre3d.org/wiki/index.php/FMOD_SoundManager
- MySQL connection - MySQL++ v3.0.8 http://tangentsoft.net/mysql++
Most of the 3D assets that comes with the game are from the OGRE SDK. Sound effects that I use came from freesound.org.
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.
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.
Similar to when I create the scene, I also broken the update function into smaller functions, each doing their own thing only.
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.
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.
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:
- A fighter jet which flies in high altitude and fires one missile at a time.
- 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.
BaseCommand- inherits from ExampleApplication
BaseCommandFrameListener- inherits from ExampleFrameListener
Fader- use to fade in and out full screen overlays
SoundManager- use to play sound effects
SteeringBehaviors- calculates the steering behavior forces
Vehicle- the enemy class. Contains a single instance of SteeringBehavior
Missile- small class that holds and updates information that the enemy fires
Bullet- holds information about the current bullet position and velocity
House- holds information about the player’s house, and trackes if its destroyed or not
- 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.
- 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.
- Decals - You probably want to show scorch mark on the terrain when a bullet and missile hits it.
- 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.
- 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.
- 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|