home *** CD-ROM | disk | FTP | other *** search
/ Game Programming - All in One (3rd Edition) / game_prog_all_in_one_3rd_ed.iso / sources / chapter19 / PlayFlick / main.c next >
Encoding:
C/C++ Source or Header  |  2006-09-16  |  1.0 KB  |  43 lines

  1. //////////////////////////////////////////////////////
  2. // Game Programming All In One, Third Edition
  3. // Chapter 19 - PlayFlick
  4. //////////////////////////////////////////////////////
  5.  
  6. #include <stdio.h>
  7. #include "allegro.h"
  8.  
  9. #define WHITE makecol(255,255,255)
  10.  
  11. int fli_callback(void)
  12. {
  13.     //display some info after each frame
  14.     textprintf_ex(screen, font, 0, 0, WHITE,0,
  15.         "FLI resolution: %d x %d", fli_bitmap->w, fli_bitmap->h);
  16.     textprintf_ex(screen, font, 0, 10, WHITE,0,
  17.         "Current frame: %2d", fli_frame);
  18.  
  19.     //ESC key stops animation
  20.     if (keypressed())
  21.         return 1;
  22.     else
  23.         return 0;
  24. }
  25.  
  26. int main(void)
  27. {
  28.     //initialize Allegro
  29.     allegro_init();
  30.     set_color_depth(16);
  31.     set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
  32.     install_timer();
  33.     install_keyboard();
  34.     
  35.     //play fli with callback
  36.     play_fli("particles.fli", screen, 1, fli_callback);
  37.  
  38.     //time to leave
  39.     allegro_exit();
  40.     return 0;
  41. }
  42. END_OF_MAIN()
  43.