Tutorial 001
Introduction to Dark Game Development
Hello and welcome to Dark Game Development blog. My name is Orpheus. I am a software engineer and a hobbyist game developer. I have started this series of tutorials to share my knowledge with everybody. I had to do a lot of R&D when the first time I started developing games, because the resources were not available or not free. So I hope this series will help you to make your games easily.
In this tutorial I will explain the life cycle of game development and some fundamental differences between standard application and a game. I will also list out the tools needed to make a complete game, and the links to find them.
I had to remove some formatting and images to make this tutorial compatible to be viewed on this blog. However, you can download the original tutorial in PDF format.
Prerequisites:
- · You should have at least working knowledge of OOP using C++. You need not be a guru, but I can not teach you C++ the language itself. I will teach how to develop a game using C++ & Dark Game Development Kit
So let’s begin!
The Virtual World
Every game has a world of its own. This world includes various entities like locations, objects, characters etc. Every entity has a life of its own. Every entity has some specific attribute & behavior.
Let’s take an example of GTA Vice City. See the image.

All these Plants, Sky, Buildings, Player, Female Characters etc are entities. The world of GTA Vice City is composed of them. These entities have a life span. They appear during the period when they are live and then they disappear. These entities can be either static or dynamic. Static entities are fixed. They do not move or animate, where as dynamic entities can. Dynamic entities can have artificial intelligence, so they can not only perform actions, but can behave in a certain manner.
Now these entities are nothing but 3D objects. We can make 3D objects using any decent tool like 3DS MAX, Maya etc. But 3D modeling can be very difficult if you are not an expert. There are also some tools available which are targeted towards specific needs. For example gameSpace (very easy for general 3D modeling), 3D World Studio (to make buildings, level, landscape etc.), TextureMaker (To make skin* for the3D objects) etc..
Skin is an image which contains colors for the 3D object. Image is always 2D, so it uses UV projection of 3D objects. If you don’t understand all this mumbo jumbo, just leave it. It’s simply a JPEG or BITMAP or DDS which will be used to color parts of 3D objects.
In this tutorial series I will not go deep into 3D modeling. Instead, I will use 3D objects which are freely available on net. Although 3D modeling is the first part of the game designing, you will soon lose patience if you are a hardcore programmer and not an artist.
To summarize, the physical structure of the entity is designed, not programmed. It’s the attribute and the behavior that is defined using the program. This is where the programming languages come into the picture. Programming languages use DirectX, OpenGL etc technologies to import these entities into a virtual 3D space. To make them behave in a certain manner we use artificial intelligence techniques, which are nothing but pure logic.
Using DirectX directly can be too difficult to handle, so we can use readymade engines which provide us a set of functions to perform basic tasks. Dark Game Development Kit is one of them and we will be using it because it is FREE to develop and distribute our games made using Dark GDK. However, if you want to sell your game, you will have to purchase a $500 license.
Although we can make our objects (entities) to behave in a certain manner without using Object Oriented Programming techniques, using OOP is always good, because as we’ve already seen, every entity is actually an object which has lifespan, attributes, and behavior which is very similar to OOP fundamentals. So we will be using
· gameSpace, 3D World Studio etc. to make landscapes, levels, static
dynamic objects
· TextureMaker to make textures for 3D objects, as well as background image for game menu
· C++ to make Classes for each object, to define attributes (member variables) and behavior (functions),
· DarkGDK (which is a function library for C++) to aid in defining the behavior, mainly to perform lower level actions like importing and placing a 3D object from file into a virtual 3D space, moving it to a specific co-ordinate etc.
The Main Loop
There is a major difference between application programming and game programming. In application, we give an interface to user and then wait for the user to fire an event. Or in old style procedure oriented program, we do everything step by step which are predefined. But in the game programming, there is a combination of both. Although the game will wait for user input, it will also start the life of other objects than the player. For example, in GTA Vice City, the enemy character won’t wait for you to pull the trigger. He has his own intelligence and will kill you if you come too close. Another example is that the female character will wander around the pool area, they will not stop for you to press forward button.
To facilitate this kind of behavior, the main program has an infinite loop running, in which you will write the main game code which will get executed in every cycle. It may seem weird right now, but soon you will get comfortable with the idea of infinite loop (which is considered a dangerous flaw in standard application programming).
So, normally your program will be like this:
1. Load the level object
2. Load all the static and dynamic objects and position them into the level
3. Declare all the flags, variables etc. Finish all the remaining settings
4. Start the main loop
5. Go to step 11 if user has
pressed Escape Key
6. Animate all dynamic characters
7. If user has pressed movement keys then move him in 3D world.
8. If user has pressed shoot key then shoot the bullet
9. If bullet has been fired then check whether it has hurt or killed somebody, if it has then act accordingly
10. Go to step 4
11. Unload all the objects from memory
12. Exit
Example
Let me show this using an example. Note that the example will not work actually because I am not showing all the small programming details. I just want to give you an overview about how your project will look.
Game.h
class Level
{
int _levelID;
char* _levelPath;
public:
Level ()
{
}
Level ( char* levelPath )
{
//Initiate level object
}
};
class Sky
{
//Define Sky
};
class Gun
{
//Define Gun
};
class ShotGun: public Gun
{
//Derived from Gun
};
class Bullet
{
//Define Bullet
};
class Player
{
int _playerID;
char* _playerPath;
Gun* _playerGun;
public:
Player ()
{
}
Player ( char* playerPath , Gun* playerGun )
{
//Initiate Player object
}
int Move ( float distance )
{
//Call DarkGDK command for moving object (here object is Player)
}
int Shoot ()
{
Bullet b;
//Call DarkGDK command for moving object (here object is Bullet)
}
~Player ()
{
}
};
class FemaleCharacter
{
//Define FemaleCharacter
void MoveAround ( float area )
{
//Call DarkGDK command for moving object (here object is FemaleCharacter)
}
};
Main.cpp
//Include header files.
#include "DarkGDK.h"
#include "Game.h"
//The main function of the project
void DarkGDK ( void )
{
//Load and Setup all the objects
Level* level1 = new Level("C:\\Obj\\level1.x");
Sky* skyDay = new Sky("C:\\Obj\\sky.x");
Player* hero = new Player("C:\\Obj\\hero.x",new ShotGun());
FemaleCharacter* fem = new FemaleCharacter("C:\\Obj\\bikinigirl.x");
//The main loop
while( /* Condition */ )
{
//Move around Female Characters in area of 1000 units
fem->MoveAround(1000);
//Move Player by 2 units if user presses Forward Key
if ( /* Condition */ ) hero->Move(2);
}
}
So you can see that apart from the differences, other aspects of programming is exactly what you already do using your normal C++.
Tools
You will need the following tools to develop game.
3D Modeling & DesigninggameSpaceLight Free Edition (Registration required, but totally FREE)3DS Max
Maya
3D World Designing3D World StudioTexturing ToolsTexture Maker 3 (Although it says Trial, it has a limited functionality mode which is more than necessary)
Adobe Photoshop
ProgrammingC++ (Visual C++ 2008 Express - FREE)Dark Game Development Kit for VC++Direct X SDK (32-bit) for VC++Direct X SDK (64-bit) for VC++Dark GDK Collision Library for VC++Direct X 9.0c RedistributableVC++ Redistributable (32-bit)VC++ Redistributable (64-bit)Dark GDK Installation:- Install Visual C++ 2008
- Install DirectX 9.0c Redist Aug2007
- Install DirectX SDK 9.0c Aug2007 (x86 for 32-bit processor & x64 for 64-bit processor)
- Install Dark GDK
To run your game on another PC you will need to bundle
- DirectX 9.0c Redist Aug2007
- VC++ Runtimes
along with your game.