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

  1. //////////////////////////////////////////////////////
  2. // Game Programming All In One, Third Edition
  3. // Chapter 19 - LoadFlick
  4. //////////////////////////////////////////////////////
  5.  
  6. #include <stdio.h>
  7. #include <allegro.h>
  8.  
  9. #define WHITE makecol(255,255,255)
  10.  
  11. int main(void)
  12. {
  13.     int ret;
  14.  
  15.     //initialize Allegro
  16.     allegro_init();
  17.     set_color_depth(16);
  18.     set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
  19.     install_timer();
  20.     install_keyboard();
  21.  
  22.     //load the fli movie file
  23.     ret = open_fli("octahedron.fli");
  24.     if (ret != FLI_OK)
  25.     {
  26.         allegro_message("Error loading octahedron.fli");
  27.         allegro_exit();
  28.         return 1;
  29.     }
  30.  
  31.     //display movie resolution
  32.     textprintf_ex(screen, font, 0, 0, WHITE,0,
  33.         "FLI resolution: %d x %d", fli_bitmap->w, fli_bitmap->h);
  34.  
  35.     //main loop
  36.     while (!keypressed())
  37.     {
  38.         //is it time for the next frame?
  39.         if (fli_timer)
  40.         {
  41.             //open the next frame
  42.             next_fli_frame(1);
  43.  
  44.             //adjust the palette
  45.             set_palette(fli_palette);
  46.  
  47.             //copy the FLI frame to the screen
  48.             blit(fli_bitmap, screen, 0, 0, 0, 30, 
  49.                 fli_bitmap->w, fli_bitmap->h);
  50.  
  51.             //display current frame
  52.             textprintf_ex(screen, font, 0, 10, WHITE,0,
  53.                 "Current frame: %4d", fli_frame);
  54.         }
  55.     }
  56.  
  57.     //remove fli from memory
  58.     close_fli();
  59.  
  60.     //time to leave
  61.     allegro_exit();
  62.     return 0;
  63. }
  64. END_OF_MAIN()
  65.