My Allegro Learning Tour 3

xiaoxiao2021-03-06  38

It is official to learn Allegro! First of all, I have to know the basic things, I use an example from the end!

#include // allegro Off File, required int Main (int Argc, char * argv []) {allegro_init (); // Initialization Allegro install_keyboard (); // Initialization keyboard set_gfx_mode (GFX_AUTODETECT, 800, 600, 0, 0); // Change our graphic mode to 800 x 600, look at the readkey (); // Waiting for the keyboard to enter return (0); // must return an int value} END_OF_MAIN (); / / This is Allegro's end main () must

Ok, now compiled, you can run, but there is no, just a scorpion screen, of course, we haven't made anything, just set the graphic mode, no matter what, no matter what, first Look, let's talk. #include , this is the necessary header files Allegro at things, of course, he wants him. All Allegro functions, variables, data structures are defined in Allegro.h

Int allegro_init (); Initializing the Allegro library. In addition to setting a global variable, locked some memory, adding allegro_exit () not doing more, but you must call before doing other things It. Successful person returns 0, failing to return non-0, (it is unlikely to call failed). There is also one of him is Install_AutodeTect, & errno, Atexit; You can see the help of Allegro.

Install_keyboard (); Initialization Keyboard, load the Allegro keyboard interrupt handler. You must call it before using any keyboard input routine. Once you set up the Allegro handler, you will no longer need to use the system call or the C library function to control the keyboard. Successful returns 0, and the failure returns a negative number.

SET_GFX_MODE (GFX_AUTODETECT, 800, 600, 0); changing our graphic mode 800 x 600, you can be other, the original shape is like this

INT set_gfx_mode (int CARD, INT W, INT H, INT V_W, INT V_H); Parameter Card can be one of the following: GFX_AUTODETECT: Allegro Select a suitable graphics driver GFX_AUTODETECT_FULLSCREEN: Allegro Select a suitable graphics driver full screen Pattern GFX_AUTODETECT_WINDOWED: Allegro Select a suitable graphics driver window mode GFX_SAFE: Allegro guarantees the correct settings of a mode GFX_Text: Return to text mode to be helpful. ReadKey (); Waiting for the keyboard input, front install_keyboard () has been defined. Look at the Readkey name, you mean what it means. Finally, end_of_main (); this is Allegro to ensure cross-platform compatibility. It is a macro, but don't have to be #ifdef, he has handled it himself.

Finally, I will say Allegro_Message ("Hello World") used in starting testing;

The prototype is such a void allegro_Message (const char * text_format, ...); use printf (); format, one message output basket. Today, I will write so much. I have a little bit of eating. It takes a little longer to write such a thing. It is not easy than the time to read the book. It is not easy.

转载请注明原文地址:https://www.9cbs.com/read-51493.html

New Post(0)