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

  1. ////////////////////////////////////////////////////////////////
  2. // Game Programming All In One, Third Edition
  3. // Chapter 8 - ScaledSprite
  4. ////////////////////////////////////////////////////////////////
  5.  
  6. #include <allegro.h>
  7.  
  8. #define WHITE makecol(255,255,255)
  9.  
  10. int main()
  11. {
  12.     BITMAP *cowboy;
  13.     int y, n;
  14.     float size = 8;
  15.  
  16.     //initialize the program
  17.     allegro_init();
  18.     install_keyboard();
  19.     set_color_depth(16);
  20.     set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
  21.  
  22.     //print some status information
  23.     textprintf_ex(screen,font,0,0,WHITE,0,
  24.         "Resolution = %ix%i", SCREEN_W, SCREEN_H);
  25.     textprintf_ex(screen,font,0,10,WHITE,0,
  26.         "Color depth = %i", bitmap_color_depth(screen));
  27.  
  28.     //load the dragon bitmap
  29.     cowboy = load_bitmap("spacecowboy1.bmp", NULL);
  30.  
  31.     //draw the sprite
  32.     for (n = 0; n < 11; n++)
  33.     {
  34.         y = 30 + size;
  35.         stretch_sprite(screen, cowboy, size, y, size, size);
  36.         textprintf_ex(screen,font,size+size+10,y,WHITE,0,
  37.             "%ix%i",(int)size,(int)size);
  38.         size *= 1.4;
  39.     }
  40.  
  41.     //delete the bitmap
  42.     destroy_bitmap(cowboy);
  43.  
  44.     while(!keypressed());
  45.     allegro_exit();
  46.     return 0;
  47. }
  48. END_OF_MAIN();
  49.  
  50.  
  51.