home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / w / wgt3_ex.zip / WGT32.C < prev    next >
C/C++ Source or Header  |  1992-09-22  |  1KB  |  68 lines

  1. #include <wgt.h>
  2. #include <conio.h>
  3. // WordUp Graphics Toolkit demo program 32
  4. // Demonstrates the use of wwarp
  5.  
  6. // Press q to quit during random shapes
  7.  
  8. int i,t,c,b;
  9. color pal[256];
  10. block wgt1;
  11.  
  12. void main(void)
  13. {
  14. int top[320];
  15. int bot[320];
  16. vga256();
  17. wgt1=wloadblock("wgt1.blk");
  18. wloadpalette("wgt1.pal",&pal);
  19. wsetpalette(0,255,&pal);
  20.  
  21. wcls(0);
  22. wclip(0,0,319,199);
  23. wsline(0,199,319,0,&top);
  24. wsline(0,199,319,199,&bot);
  25. wwarp(0,319,&top,&bot,wgt1);
  26. getch();
  27. // squish it
  28.  
  29. wcls(0);
  30. wsline(0,100,100,0,&top);
  31. wsline(101,70,218,70,&top);
  32. wsline(219,0,319,100,&top);
  33.  
  34. wsline(0,100,100,199,&bot);
  35. wsline(101,130,218,130,&bot);
  36. wsline(219,199,319,100,&bot);
  37. wwarp(0,319,&top,&bot,wgt1);
  38. getch();
  39. // make a double arrow
  40.  
  41. wcls(0);
  42. do {
  43. b=rand() % 100;
  44. c=(rand() % 100)+100;
  45. for (t=0; t<=319; t++)
  46.   {
  47.   i=rand() % 2;
  48.   if (i==0) b++; else b--;
  49.   i=rand() % 2;
  50.   if (i==0) c++; else c--;
  51.   if (b>100) b=100;
  52.   if (b<0) b=0;
  53.   if (c>197) c=197;
  54.   if (c<100) c=100;
  55.  
  56.   top[t]=b;
  57.   bot[t]=c;
  58.   }
  59. wwarp(0,319,&top,&bot,wgt1);
  60. i=getch();
  61. wcls(0);
  62. } while (i !='q');
  63. // do random shapes
  64.  
  65. wfreeblock(wgt1);
  66. textmode(C80);
  67. }
  68.