html5-img
1 / 7

Allegro Basics

Allegro Basics. Game Library. What is Allegro?. Allegro is a cross-platform library intended for use in computer games and other types of multimedia programming. Cross-platform support for Windows, Unix, and MacOS X systems. . License?. The giftware licence

ganit
Télécharger la présentation

Allegro Basics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Allegro Basics Game Library

  2. What is Allegro? • Allegro is a cross-platform library intended for use in computer games and other types of multimedia programming. • Cross-platform support for Windows, Unix, and MacOS X systems.

  3. License? • The giftware licence • Feel free to use the code for whatever you want – just do not claim that you wrote it!

  4. Using Allegro • any source file which used Allegro functions or variables must #include <allegro.h>Put this after any standard header files • you should call allegro_init() near the start of your program. • make allegro_init() the first thing in your main function.

  5. More on Allegro Usage • write END_OF_MAIN() after the closing brace of your main function. If you don't do this, your program will not link properly with the Allegro library. • Link with the appropriate Allegro Library

  6. What does a game need to do? • Initialization - First of all we need to put the game into a known state, so that it always starts in the same way. For example, you might want to start the player in the middle of the screen, make a maze, or create a random map. All that would go in here. • Main game loop The game will need to keep doing things, over and over again, until the player dies, wins, gives up, or whatever. So we have a main game loop. It has three main components: • Input -- getting input from the player • Processing -- moving things around, responding to the input • Output -- sending information back to the player, usually by putting it on the screen but sometimes by other means, for example playing sounds • After the game - When the game has finished, we may need to do some other things, like tell the player why it finished, update a high score table, or something like that

  7. Proposed Main #include <allegro.h> #include "game.h" intend_game; /* flag we'll set to end the game */ int main (void) { allegro_init(); /* initialise the Allegro library */ init(); /* initialise the game */ end_game = 0; /* reset flag */ do { /* loop */ input(); /* get input */ process(); /* process it */ output(); /* give output */ } while (end_game == 0); /* until the flag is set */ shutdown(); /* shut down anything that needs it */ allegro_exit(); /* just for luck */ return 0; /* tell the OS that all went well */ } END_OF_MAIN()

More Related