home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / asp / part01 / anim.c next >
Encoding:
C/C++ Source or Header  |  1991-10-16  |  1.6 KB  |  73 lines

  1. /*
  2.  * This code is copyright ADE Muffett, September 1991, and is distributed as
  3.  * part of the ASP .plan description language compiler.  This code is freely
  4.  * redistributable as long as this copyright notice remains intact. No
  5.  * responsibility is assumed by the author for any situation which arises
  6.  * from the use of this code, including insanity, late nights, or disk
  7.  * storage problems.
  8.  */
  9.  
  10. #include "asp.h"
  11.  
  12. void
  13. AddObject (string)
  14.     char *string;
  15. {
  16.     register int i;
  17.     int start;
  18.     int finish;
  19.     char buff[SCREENWIDTH];
  20.     char *obj;
  21.  
  22.     sscanf (string, "%*s %s %d %d", buff, &start, &finish);
  23.  
  24.     obj = CopyString (buff);
  25.  
  26.     for (i = 0; aobjects[i].object && (i < MAX_ANIM_OBJS - 1); i++);
  27.  
  28.     aobjects[i].object = obj;
  29.     aobjects[i].location = start;
  30.     aobjects[i].destination = finish;
  31.     aobjects[++i].object = NULL;
  32. }
  33.  
  34. void
  35. ResetAnim ()
  36. {
  37.     aobjects[0].object = NULL;
  38.     NullSet (anim_buffer, sizeof (anim_buffer));
  39. }
  40.  
  41. void
  42. Animate ()
  43. {
  44.     register int i;
  45.     struct anim_object *ap;
  46.     int changed;
  47.  
  48.     for (changed = 1; changed; /* nothing */ )
  49.     {
  50.     changed = 0;
  51.     NullSet (anim_buffer, sizeof (anim_buffer));
  52.     SpaceFlood (anim_buffer, SCREENWIDTH);
  53.  
  54.     for (i = 0; aobjects[i].object && (i < MAX_ANIM_OBJS - 1); i++)
  55.     {
  56.         ap = &aobjects[i];
  57.  
  58.         LimCopy (anim_buffer, ap -> object, ap -> location);
  59.         if (ap -> location > ap -> destination)
  60.         {
  61.         ap -> location--;
  62.         changed++;
  63.         } else if (ap -> location < ap -> destination)
  64.         {
  65.         ap -> location++;
  66.         changed++;
  67.         }
  68.     }
  69.     /* anim_buffer is dealt with in Update() for masking reasons */
  70.     UpdateCR ();
  71.     }
  72. }
  73.