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

  1. /*   WORDUP Graphics Toolkit   Version 3.0
  2.      Demonstration program 23
  3.  
  4.      Make a large 256 colour, animating mouse cursor!
  5.  
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <dos.h>
  10. #include <conio.h>
  11. #include <stdlib.h>
  12. #include <alloc.h>
  13. #include <wgt.h>
  14. #include <spr.h>
  15.  
  16. int i;
  17. color palette[256];            // the palette
  18. block sprites[201];            // all the sprites
  19. int quit;                // if quit !=0, program quits
  20.  
  21. void looper(void);            // a routine which controls the sprites
  22.  
  23. void main(void)
  24. {
  25. vga256();
  26. wloadsprites(&palette,"mouse.spr",sprites);    // load them
  27. initspr();                    // initialize them
  28. spon=1;                    // number of sprites on
  29. minit();
  30.  
  31. for (i=0; i<200; i++)        // draw a background
  32.   {
  33.   wsetcolor(i);
  34.   wline(0,i,159,i);
  35.   wline(160,199-i,319,199-i);
  36.   }
  37.  
  38. wcopyscreen(0,0,319,199,NULL,0,0,spritescreen);
  39. // when using sprites, whatever is on the visual page must be on
  40. // spritescreen too!
  41.  
  42. // Also, you must make sure you turn a sprite on AFTER you draw
  43. // the background or it will leave a black spot where the sprite 
  44. // is first shown.
  45. wsetscreen(spritescreen);
  46. spriteon(1,160,100,1);                // turn on any sprites
  47.  
  48. animate(1,"(1,30)(2,30)(3,30)(4,30)(3,30)(2,30)R");
  49. animon(1);
  50. // animate the sprite
  51.  
  52.  
  53.  
  54.  
  55. do {
  56. looper();
  57. } while (!quit);
  58.  
  59.  
  60. spriteoff(1);            // turn off sprites
  61. // To be safe, turn off all sprites before ending program.
  62. // This will free any memory used from them.
  63.  
  64.  
  65. wfreesprites(sprites);        // free memory
  66. wfreeblock(spritescreen);
  67. wcls(0);
  68. textmode(C80);
  69. }
  70.  
  71.  
  72. void looper(void)
  73. {
  74. erasespr();            // clear the sprites
  75.  
  76. mread();
  77. s[1].x=mx;            // any direct sprite movements must be placed
  78. s[1].y=my;            // between erasespr and drawspr
  79. // This will place sprite number 1 where the mouse cursor is.
  80.  
  81.  
  82. drawspr();            // draw them back on
  83. if (kbhit()) quit=1;
  84. }
  85.