Tactics Squad

Home News Downloads Bug Report Screenshots Design

Game design

Welcome to the newest section of the Tactics Squad homepage. If you are interested in how to make a game, or just want to know how Tactics Squad works, then this section is for you. Let's first have a look at the...

Preliminary choices

The first choice one has to make when writing a program is obviously the language. Before starting the game, I already had a lot of experience in C and a little in C++. I like to see Tactics Squad as a way of learning more, more about programming, more about game design... In this sense, I chose the language of which I had worse knowledge, C++, as the programming language for Tactics Squad. So in the code you will find my first attempts at using vectors, for instance.

Apart from my wish of learning more C++, I chose the language because it is fast, clean, efficient, standard, widely used and, above all, object-oriented programming is the easiest, clearest way of describing to your computer how a game works. If you don't already know C++ I strongly suggest you to take a look at it. Besides, you won't be able to read the source code of Tactics Squad without knowing C++.

The second choice, particularly in a game, is how are you going to handle graphics and sound. You can do it from scratch or use an already known library. For Windows, you have DirectX, which is the standard in the game industry. In my experience, programming with DirectX, particularly Direct3D, is quite the punishment. I haven't done that in the last five years, so maybe this has changed. When I became fed up with DirectX I switched to OpenGL, which was a relief. Things that took me months to learn to do in Direct3D were working and running in OpenGL in a few days, and in a lot less lines.

OpenGL became the graphics library and I intended to have DirectSound, which is relatively easy to work with, for the sound. This was until Tactics Squad v0.25, then I discovered the SDL library. If you don't already know of this library, I can tell you that SDL is the casual game programmer's dream. It provides you with such a solid foundation, it gives you graphics, sound and input handling, fully compatible with OpenGL, with the added blessing of completely cross-platform code.

A third choice, of lesser importance, is the compiler and IDE. Up until version 0.25, I used Microsoft's Visual C++ 2005 Express Edition. It offers a very nice IDE and a good compiler. However, once the switch to SDL was made, I figured that since the code was going to be portable, maybe it was a good idea to use a more universal compiler, and that means g++. That's when I discovered Code::Blocks, a fantastic IDE, not as good as Visual C++, but much lighter and convenient since it includes gcc and g++. Definitely worth a look.

Once the first development choices are made, let's get on to the...

Foundations

By foundations I mean the basic code required for making the game run, display something, have a little user input, and exit. If you want to have a look at how the Tactics Squad foundations were, take a look at release 0.1 at SourceForge. This release simply displayed the game's main menu, let the user change some display settings and that's it. It proved to be a quite solid foundation, but it had to be slightly rewritten to adapt to the SDL library.

The best way to understand how the game works is, obviously, reading the source code. The code is divided into the following files:

Tactics.cpp: The starting point, contains the game loop, event handler, and start routines.
GLLib2D.h and GLLib2D.cpp: Graphic library. Font handling, image loading... It's all done here.
GUI.h and GUI.cpp: GUI utilities, used for the Main Menu.
Map.h and Map.cpp: The map files, it contains the map definitions and pathfinding algorithms.
Legionary.h and Legionary.cpp: Code for the soldier.
Msg.h and Msg.cpp: Defines the transmission log.
Command.h and Command.cpp: For the operation of the CSTI, the six icons on the top left of the screen.
SFX.h and SFX.cpp: Sparks, grenades, explosions... are all defined here.
SndLib.h and SndLib.cpp: Sound library.

The code is terribly non linear. The game flow jumps between many handlers, the Main Menu Handler (GUI.h), the Map Handler (Map.h), the Message Handler (Msg.h)... The two most important functions each handler has are: ReadInput(MouseData, KeybData) and Beat(). The first one gets the user input and the second one does whatever this handler should do for the current frame.
SourceForge.net Logo Support This Project