Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Allegro Newbie Tutorial

2pi

Newbie Spellweaver
Joined
Oct 30, 2009
Messages
40
Reaction score
2
Allegro is a game programming library for C/C++ developers distributed freely, supporting the following platforms: Unix (Linux, FreeBSD, etc.), Windows, MacOS X and Haiku/BeOS. Older versions also support DOS and QNX. It provides many functions for graphics, sounds, player input (keyboard, mouse and joystick) and timers. It also provides fixed and floating point mathematical functions, 3d functions, file management functions, compressed datafile and a GUI.
This tutorial will teach you,how to use this powerful library.So let's code:w00t:
From now I assume that you have a c langue knowledge,else you can find many c tutorial in the internet.
See to learn how install the allegro in your computer
Create a new project and paste that code:
Code:
#include <allegro.h>

int main()
{
    allegro_init();
    install_keyboard();
    set_color_depth(32);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
    readkey();
    return 0;
}END_OF_MAIN()
Compiling'll appear a black window,all rigth now let's see what each part of the code means:

Code:
#include <allegro.h>
Here we declarate the allegro.h hearder

Code:
 allegro_init();
A fuction to start allegro

Code:
 set_color_depth(32);
Set the color depth(older computers may don't support 32,so you can change to 16)

Code:
set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
set_gfx_mode will set the graphics mode that you will use in your program. Here is what each paramater is:

set_gfx_mode(GRAPHICS MODE, Width, Height, Virtual Width, Virtual Height);

* Using GFX_AUTODETECT for a graphics mode will set everything for you, using the machine's preinstalled drivers.
* The width and the height are simple that, the width and the height of the screen.
* The V_Width and V_Height are the virtual (not visible) width and height of the screen. (We don't need to worry about these for the moment, so entering zeros will just create NO virtual screen.)

Code:
readkey();
Wait until a key be pressed

Code:
END_OF_MAIN()
This function is mandatory allegro, indicates that "main()" just

I hope you enjoyed the tutorial, I'll post soon other

More tie!:p:
 
Back
Top