home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / WGT_TC21.ZIP / WGT09.C < prev    next >
C/C++ Source or Header  |  1992-07-17  |  1KB  |  57 lines

  1. #include <conio.h>
  2. #include "c:\tc\wgt\wgt.h"
  3. /*   WORDUP Graphics Toolkit   Version 2.1
  4.      Demonstration program 9
  5.  
  6. Shows how the block functions work
  7.  
  8. */
  9.  
  10. int i,x,y;
  11. color palette[256];
  12. block screen1;            // a full screen
  13. block part1;            // part of the screen
  14.  
  15.  
  16. void main(void)
  17. {
  18. vga256();        // initializes system
  19.  
  20.  
  21. for (y=1; y<64; y++)        
  22.    wsetrgb(y,y,y,y,&palette);       // sets first 64 colours to grey
  23.                     // note the use of &
  24. for (y=0; y<64; y++)
  25.    wsetrgb(y+64,y,0,0,&palette);        // next 64 to red
  26. for (y=0; y<64; y++)
  27.    wsetrgb(y+128,0,y,0,&palette);       // green
  28. for (y=0; y<64; y++)
  29.    wsetrgb(y+192,0,0,y,&palette);    // blue
  30.  
  31.    wsetrgb(1,63,63,63,&palette);       // sets color 1 to white
  32.  wsetpalette(0,255,palette);        // and finally change them
  33.                     // all at once
  34.  
  35. for (i=1; i<200; i++)
  36.    {
  37.    wsetcolor(i);
  38.    wline(0,i,319,i);
  39.    }
  40.  
  41. screen1=wnewblock(0,0,319,199);        // capture the entire screen
  42. part1=wnewblock(100,100,150,150);    // get a part of the screen
  43. wcls(0);
  44.  
  45. do {
  46.   x=rand() % 320;
  47.   y=rand() % 200;
  48.   wputblock(x,y,part1,0);        // put the part somewhere
  49.   } while (!kbhit());
  50. getch();
  51. wputblock(0,0,screen1,0);        // replace the mess with the
  52.                     // original screen
  53. getch();                // get the key
  54. wfreeblock(screen1);            // *** make sure to free the memory!
  55. wfreeblock(part1);
  56. textmode(C80);                // used to return to text mode
  57. }