Bang! is a third person shooter with a lot of action. You will have to kill all the guards in the banks to be able to rob the money. I have make the bottom picture yet, the presentation and levels to the end. At the moment when a guard is shot simply it fall over but I want to make a lot of coins jumping from the guard when shot. At the moment there is only one kind of guard. I look forward to make several of them each one with its own behaviour. Each level they will be cleverer.

Post tutorial Report RSS Main file (main.cpp)

I would like to share with you all the game's main file "main.cpp". It's a bit disorderly so far. In the first lines of the code we can read the #include directives. The game is using the Allegro library (4.2 for Linux in this case). Another line is the #include "protagonist.h" where I have all the variables and methods than control the protagonist's behaviour. The - #include "enemy.h" - is to include the class enemy. In this class we have the data members and methods that control the guards.

Posted by on - Basic Client Side Coding

What are those header files (.h) ?

This tutorial is for all those starting learning C++. If you are a developer you will find this a bit boring.

Next we can see the first lines of the main file (main.cpp) of the game written in C++.

#include "allegro.h"
//#include "allegro5\allegro.h

#include <time.h>
#include <stdlib.h>
#include "protagonist.h"
#include "enemy.h"
#include "environment.h"
#include "induction.h"
#include "common.h"
#include "indicators.h"


"protagonist.h", "enemy.h" are called header files.When the program we want to make is large enough it is much better to structure the code in several files not only one.So we will have several header files and their correspondents .cpp files. In the header files we will declare data members (variables) and methods (functions) whereas in the .cpp files we will define them.The "include" directive just copy and paste the file. That's all.We will use " " for all those header files that we code. (e.g. "#include "protagonist.h"). I wrote that file so I use " ".
We will use < > for those belonging to other libraries like the standard library of c++, allegro, etc (e.g #include ). I did not write that file for the game so I use < >.

How is structured the game?

In the header file "protagonist.h" I have the class protagonist which contains all the data member and methods that determine characteristics and behaviour of the protagonist, the character you can see in the middle of the screen.In the header file "enemy.h" I have the class enemy with all the data members and methods that control the guards.These two are the main parts of the program so far.

What is next?

I think that this is a good game to follow for all of you who are learning coding because it is coded from the scratch without game engines. In other tutorials I will keep on explaining other parts of the code.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: