home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / rehack / demosrc / gscrtest.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-17  |  1.1 KB  |  52 lines

  1. //        gscrtest.cpp
  2. //        test code for Gscreen class
  3.  
  4.  
  5. #include <conio.h>
  6.  
  7. #define Gscreen_test
  8.  
  9. #include "Gscreen.cpp"
  10.  
  11. const int CURUP =72;
  12. const int CURDN =80;
  13. const int CURLF =75;
  14. const int CURRT =77;
  15. const int ESCKEY=27;
  16.  
  17. int main()
  18. {
  19.     char ch;
  20.  
  21.     Gscreen screen;        // will default to 0x13
  22.     const char far *image_ptr = screen.unpackpcx ("walk24.pcx");
  23.     BitMap bmp (image_ptr);
  24.     bmp.set (320, 200, 120, 96, 24, 24, 5, 4);
  25.     screen.setpalette ();
  26. //    screen.display ();
  27.     int dir=0;
  28.     int incx=0, incy=0;
  29.     int scrx=100;
  30.     int scry=150;
  31.     while (ch!=ESCKEY) {
  32.         bmp.display (scrx, scry, 0,dir);
  33.         ch=getch();
  34.         if (ch==0) ch=getch();
  35.         switch (ch) {
  36.             case CURRT: dir=0; incx= 1; incy= 0; break;
  37.             case CURLF: dir=1; incx=-1; incy= 0; break;
  38.             case CURDN:    dir=2; incx= 0; incy= 1; break;
  39.             case CURUP:    dir=3; incx= 0; incy=-1; break;
  40.         }
  41.         bmp.erase ();
  42.         for (int i=1; i<4; i++) {
  43.             scrx+=incx*4;
  44.             scry+=incy*4;
  45.  
  46.             bmp.display (scrx, scry, i, dir);
  47.             for (long counter=0; counter < 50000L; counter++);
  48.             bmp.erase ();
  49.         }
  50.     }
  51. }
  52.