Wednesday, July 7, 2010

Tutorial: Allegro, The Game Programming Library in C/C++

  • Beginners tutorial. ( offline tutorial ) programmers are advised to use this material in the beginning level.
  • Beginners tutorial. ( online tutorial )
  • Allegro API. ( pdf )
  • How to make Pong game.( offline tutorial )
  • Allegro Newbie Tutorial, provided with example projects for beginners. ( online tutorial )
  • C and C++ Allegro tutorial. ( online tutorial )
  • C++ and Allegro tutorial, provided with example projects for beginners. ( online tutorial )
  • Process of making a simple game from scratch. ( online tutorial )
  • Scripting and Allegro. ( online tutorial )
  • Gillius's Programming Tutorial. ( online tutorial )
  • Game Developing Community Network, for getting sample projects and recent updates. ( community )
  • Allegro: get sample Projects,updates and advanced Tutorials Link-1.
  • Allegro: get sample Projects,updates and advanced Tutorials Link-2.
  • Allegro: Learning with the aid of Examples(good for Beginners). ( online )
  • Allegro manual. ( online ). programmers are advised to use this material in the advanced level.
Here are some sample projects( Games), which might help you in beginning with allegro.

Portability of Applications buit on Allegro library

Suppose, you have developed an application at home using Allegro library on the portable version of Dev C++( which is present on your USB drive), then it will run fine on your system, whether you run the application by double-clicking the application icon or from IDE by going to (Execute -> Compile) and then (Execute -> Run).
But, when you try to run the same application program on your friends system(which is neither installed with Allegro packages nor with Dev C++ IDE) , will it run fine ?
The answer depends on how you are going to run the application.
If you try to run the application from the portable IDE( the one which I carried on my USB drive ) by going to (Execute -> Compile) and then (Execute -> Run), the application will run fine.
But, if you run the application by double-clicking the application icon it will pop up an error saying that, "alleg42.dll was not found", though the allegro package is present on your portable IDE.

It doesn't mean that your application is not portable. To avoid this error, just reinstall the allegro packages on to your portable IDE. This process will automatically copy all the necessary dll(Dynamic-link library) files, including alleg42.dll file on to your friends system. That's it. Now, again run the application program by double-clicking it. It will surely run.
Here, you have installed the dependencies( i.e., dll files ) on to your friend's system.

Getting Started With Allegro: the game programming library in C/C++

For the beginners, here is a simple tutorial that will guide you in getting started with Allegro library:
  • Run the IDE and create a new Allegro project by selecting File -> New -> Project.
  • From the pop-up window, select Multimedia -> Allegro Application -> C++ Project -> (Enter the Project name as "TestAllegro") -> Click 'Ok'.
  • Now, a window will pop-up asking you to save the project at some location. Save the project at "D:\Example Allegro" and press save button.
  • Now a new Project named "TestAllegro" will be created under the path "D:\Example Allegro". A sample file named main.cpp, that includes allegro.h will also be generated by default, but it is not yet, saved in any directory.

  • As you are having a sample source code file i.e., main.cpp, you can compile the project. When you compile the project, all the output files and intermediate files that are generated during compilation will be saved in the directory where project is saved. In this case, it is "D:\Example Allegro".
  • But you have not saved the source file main.cpp. So, a window will pop-up asking you to specify the location where you wan to save the source file main.cpp. Again specify the path for source file as, "D:\Example Allegro".
  • Now, the project will compile successfully and a Compile progress window will pop-up giving you the status as Done. If, it doesn't happen then there might be something wrong with your source code.
  • Now, run the the project from the IDE.
  • By default, the close and restore Down/Maximize buttons of the window are disabled. It order to enable them user must insert his own code which will specify the functionality of those buttons.
  • Use task manager to kill the window.
  • You can even run the application window by, double-clicking the executable file, which is of application type.By default, the executable file is generated under the same directory where the project is saved and the executable file will also take the same name as that of the project. In this case the directory is "D:\Example Allegro" and the executable files is TestAllegro.exe.

Tuesday, July 6, 2010

Allegro: The Game Programming Library Installation

Allegro is one of the best game programming libraries that are are available in C/C++.
This library enables you to program your own applications and games in C and C++, and is very much better than the graphics.h( Supported by Turbo C++ and Borloand C++).
It is even enables you, to play media files like avi files using the AllegAvi library (comes under the family of Allegro) from your own C or C++ program.
You can even display the pictures( BMP ) using your own C or C++ Program.
View the list of all the libraries that come under the family of allegro.

Allegro is compatible with both Windows and Linux.
Linux users can get the installation tutorial over here.
Windows users can use the IDE Dev C++, added with Allegro packages for designing their own games and applications.
Installation of allegro package in Dev C++ ( Dev C++ IDE is available only for Windows )
  • Download Dev C++ either portable version(does'nt need any installation ) or normal version(Should be installed). I recommend you to use the portable version.
  • Download the game programming library Allegro.
  • To add the Allegro packages to the IDE, run the IDE and go to Tools -> Package Manager.
  • From the pop-up window, click Install button.
  • Select and open the downloaded Alegro file.
  • Now, you can see that Allegro packages have been added to your IDE.