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 / WGT25.C < prev    next >
C/C++ Source or Header  |  1992-09-08  |  2KB  |  96 lines

  1. /*   WORDUP Graphics Toolkit   Version 3.0
  2.      Demonstration program 25
  3.  
  4.      Good practice for understanding the movement commands.
  5.      See if you can guess what each move will do before you
  6.      run this program.  It will help you understand the format
  7.      for the movements.
  8.  
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <dos.h>
  13. #include <conio.h>
  14. #include <stdlib.h>
  15. #include <alloc.h>
  16. #include <wgt.h>
  17. #include <spr.h>
  18.  
  19. int i;
  20. color palette[256];            // the palette
  21. block sprites[201];            // all the sprites
  22. int quit;                // if quit !=0, program quits
  23.  
  24. void looper(void);            // a routine which controls the sprites
  25.  
  26. void main(void)
  27. {
  28. vga256();
  29. wloadsprites(&palette,"mouse.spr",sprites);    // load them
  30. initspr();                    // initialize them
  31. spon=4;                    // number of sprites on
  32. minit();
  33.  
  34. for (i=0; i<200; i++)        // draw a background
  35.   {
  36.   wsetcolor(i);
  37.   wline(0,i,159,i);
  38.   wline(160,199-i,319,199-i);
  39.   }
  40.  
  41. wcopyscreen(0,0,319,199,NULL,0,0,spritescreen);
  42. // when using sprites, whatever is on the visual page must be on
  43. // spritescreen too!
  44.  
  45. // Also, you must make sure you turn a sprite on AFTER you draw
  46. // the background or it will leave a black spot where the sprite 
  47. // is first shown.
  48. wsetscreen(spritescreen);
  49. spriteon(1,0,0,1);        
  50. animate(1,"(1,30)(2,30)(3,30)(4,30)(3,30)(2,30)R");
  51. movex(1,"(2,150,0)(0,90,0)(-2,150,0)(0,90,0)R");
  52. movey(1,"(0,150,0)(2,90,0)(0,150,0)(-2,90,0)R");
  53.  
  54. spriteon(2,160,0,1);        
  55. animate(2,"(1,30)(2,30)(3,30)(4,30)R");
  56. movex(2,"(-1,150,0)(1,300,0)(-1,150,0)R");
  57. movey(2,"(1,180,0)(-1,180,0)R");
  58.  
  59. spriteon(3,0,100,1);        
  60. animate(3,"(1,30)(4,30)R");
  61. movex(3,"(1,300,1)(-300,1,0)R");
  62. movey(3,"(0,1,0)");                // must set a y move since
  63.                         // I turn it on below even
  64.                         // if it doens't do anything
  65. for (i=1; i<4; i++) {
  66. animon(i);
  67. movexon(i);
  68. moveyon(i); }
  69.  
  70.  
  71. do {
  72. looper();
  73. } while (!quit);
  74.  
  75.  
  76. spriteoff(1);            // turn off sprites
  77. spriteoff(2);            // turn off sprites
  78. spriteoff(3);            // turn off sprites
  79. // To be safe, turn off all sprites before ending program.
  80. // This will free any memory used from them.
  81.  
  82.  
  83. wfreesprites(sprites);        // free memory
  84. wfreeblock(spritescreen);
  85. wcls(0);
  86. textmode(C80);
  87. }
  88.  
  89.  
  90. void looper(void)
  91. {
  92. erasespr();            // clear the sprites
  93. drawspr();            // draw them back on
  94. if (kbhit()) quit=1;
  95. }
  96.