Allegro Tutorial!! (This document looks best maximized.) For all of you who have no idea what allegro is, It is a game programming library for DJGPP. It is extremely easy to use, and even new people in C can use it without problems. I am not going to explain how to install it, because there is already a document on it. Also, this is for version 2.2. Mainly because 2.1 doesn't work. If you know Inline Assembly you could fix it. But if you know Inline Assembly, you wouldn't be reading this now would you. Heck you could write your own Allegro. On with the tutorial. We are going to start with the basics. I'm assuming you know that DJGPP is a C/C++ Compiler, so I'm going to do all these things in C. Now we have to think, what is our main game loop going to look like? Well there are many ways to do it, but I'd use this. #include //Standard I/O routines. #include //Anything else you want to use? #include "allegro.h" //Allegro header file #include "game.h" //Header file produced by Grabber. You don't need this. int flag=0; void main() { while (flag=1) { //code goes here. } } That is a standard game loop. This is mainly to put it into a loop. If you wanted them to go back to the menu, you would call a function, not set flag to 1. If I'm right, and I could be wrong, this would exit out of your program. Next we will see how to start up allegro. This is very easy, and takes no brains whatsoever. All you have to do is type: allegro_init(); Now lets see what allegro can do. Now what do we need to do before puting any graphics? We have to set the graphics mode. This is extremely easy. Just type: set_gfx_mode(0, 0, 320, 200); or for a higher resolution set_gfx_mode(0, 0, 640, 480); Easy isn't it. That is all you have to do! Now, I am not going to go over the next step, because I'm not sure how to use these set of routines, and you probably wont have a need for them. I'm going to skip right ahead on how to do the keyboard. The first think we must do is install the timer. You have to do this before you can get the Allegro Keyboard Routines to work. This is not hard just type: install_timer(); Self Explanatory. Install timer. Now we have to install the keyboard. This is even easier: install_keyboard(); Still very easy. Now lets test for a keypress. I'm not going to make a big table of all the keys, because it's very long. Plus they are not to hard to figure out. I'm going to make a up down left and right one though. if(key[KEY_LEFT]) x--; if(key[KEY_RIGHT]) x++; if(key[KEY_UP]) y--; if(key[KEY_DOWN]) y++; This is assuming that the players position variables are x, and y. Well that is the end of the first chapter. Next week we will be talking about Graphics.