First: Head over to the synaptic package manager and mark for install the Allegro libraries. This is easiest found using the handy search feature located conveniently atop of the package manager.
Once installed fire up Code::Blocks, this is where a little problem I encountered occurred.
Allegro is not linked up to Code::Blocks by default so in your IDE select Settings > Compiler and Debugger > Linker Settings and type the following into "Other linker options"
`allegro-config --libs --static`

Be sure to include the back ticks as well. That should take care of it. Not to difficult to do but seems a lot of people experienced some problems getting Allegro to work with Code::Blocks.
Now lets test Allegro out.
Open up a new file in Code::Blocks and name it something like allegroTestFile.c and enter the following code:
#include <allegro.h>
int main()
{
//Initialize Allegro
allegro_init();
//Set the resolution to 640 x 480 with SAFE autodetection.
set_gfx_mode(GFX_SAFE, 640, 480, 0, 0);
//Install the keyboard handler
install_keyboard();
//Print your welcome message to the screen
textout(screen, font, "Hello Dream.In.Code! This is my first Allegro Program", 1, 1, 10);
textout(screen, font, "Press ESCape to quit.", 1, 12, 11);
//Loop until escape is pressed
while(! key[KEY_ESC])
poll_keyboard();
//Exit program
allegro_exit();
return 0;
}
END_OF_MAIN();
Press f9 to compile and run!
Here is an image of the final result - Enjoy!

Portions of this code as well as more detailed information regarding game programming with the Allegro Library can be found in Jonathon Harbour's "Game Programming All In One - 2nd Edition"
Please feel free to comment if you have any questions or concerns.






MultiQuote





|