C++ Game Programming
Basic C++ Lessons
This set of lessons will give you a simple introduction to programming in the C++ language.
Allegro Lessons
This set of lessons will demonstrate how to use the Allegro graphics library to create video games.
Game Source Code
Here you will find source code to several games so that you can see the code in action.
Recommended Books
Here is a list of books which should help you with C++

Allegro Basics
Here I will show you the very basics of programming with the Allegro Game Library. First of all, you will need to download and install Allegro. This can be a bit of a pain on Windows. Luckily, if you are using Dev-C++, you will be able to find a link to a file which will install allegro for Dev-C++ with a few clicks of the mouse! You can find it at the bottom of the download section in the Allegro website. If you are not using Dev-C++, please refer to the documentation provided on the Allegro site for installation instructions. Also be sure to install Allegro version 4.1.18, even though it is still 'Developmental', it is required for some of the examples on this site.

Now that that's out the way, lets get down to business! Open a new project in Dev-C++, be sure to pick "Windows Application". Now click on "Project" in the menu bar then "Project Options". Choose "Parameters" then click "Add Library or Object", set this to "C:\Dev-Cpp\lib\liballeg.a". This will let the compiler know where to find the Allegro functions. Here a simple Allegro program:


#include <allegro.h>


int main(){
 
    allegro_init();
    install_keyboard();
    set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);
    
    readkey();
    
    return 0;
    
}   
END_OF_MAIN(); 

This program will change the screen resolution to 640x480 and then wait for the user to press a key and then exit. Lets break down the code.

The first difference you will notice from the basic C++ lessons and these is that we no longer need to include iostream, allegro includes all the functions we will need for now. In order to startup Allegro we have to run the allegro_init() function, it does not require any information on your part, just remember to have this line before you start using any Allegro functions in your program!

install_keyboard() prepares Allegro to take user input from the keyboard, I will get more in depth with the Allegro input functions in a later lesson. set_gfx_mode() changes the screen resolution, it takes five parameters. The first should always be set to "GFX_AUTODETECT". The next two will be the size of the viewable screen. The last two are used for programs that require even more space, but that is a whole other lesson.

Google