home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 013.lha / fish / init.c < prev    next >
C/C++ Source or Header  |  1986-11-10  |  4KB  |  228 lines

  1. /* init.c */
  2. /***************************************************************/
  3. #include "fishes.h"
  4. #include <stdio.h>
  5.  
  6. #define DEPTH 3 
  7. #define ALLSTART 0
  8. #define TEST
  9.  
  10.  
  11. extern short color[8];
  12. extern short color1[8];
  13. extern short color2[8];
  14.  
  15. short color92[] = {
  16. 0x28f,
  17. 0xffc,
  18. 0xfbf,
  19. 0xfd0,
  20. 0xf30,
  21. 0x90d,
  22. 0xff,
  23. 0xd9,
  24. };
  25.  
  26. extern struct AnimOb fishOb;
  27. extern struct Bob fish1Bob;
  28. extern struct AnimComp fish1Comp;
  29.  
  30. extern struct GelsInfo *GInfo;
  31. extern struct VSprite *head, *tail;
  32. extern struct collTable *boom;
  33.  
  34. SHORT timers[] =
  35. {
  36. /* fish's */
  37.     1, 1, 1, 1, 1, 1, 1, 1, 1,1,1,1,1, 1, 1, 1, 1,
  38. };
  39.  
  40. SHORT Index = 0;
  41.  
  42. SHORT xtranslations[] = 
  43. {
  44. /* fish's */
  45.     0 << ANFRACSIZE,
  46.     0 << ANFRACSIZE,
  47.     0 << ANFRACSIZE,
  48.     0 << ANFRACSIZE,
  49.     0 << ANFRACSIZE,
  50.     0 << ANFRACSIZE,
  51.     0 << ANFRACSIZE,
  52.     0 << ANFRACSIZE,
  53.     0 << ANFRACSIZE,
  54.     0 << ANFRACSIZE,
  55.     0 << ANFRACSIZE,
  56.     0 << ANFRACSIZE,
  57.     0 << ANFRACSIZE,
  58.     0 << ANFRACSIZE,
  59.     0 << ANFRACSIZE,
  60.     0 << ANFRACSIZE,
  61.     0 << ANFRACSIZE,
  62. };
  63.  
  64. SHORT ytranslations[] = 
  65. {
  66. /* fish's */
  67.     0 << ANFRACSIZE,
  68.     0 << ANFRACSIZE,
  69.     0 << ANFRACSIZE,
  70.     0 << ANFRACSIZE,
  71.     0 << ANFRACSIZE,
  72.     0 << ANFRACSIZE,
  73.     0 << ANFRACSIZE,
  74.     0 << ANFRACSIZE,
  75.     0 << ANFRACSIZE,
  76.     0 << ANFRACSIZE,
  77.     0 << ANFRACSIZE,
  78.     0 << ANFRACSIZE,
  79.     0 << ANFRACSIZE,
  80.     0 << ANFRACSIZE,
  81.     0 << ANFRACSIZE,
  82.     0 << ANFRACSIZE,
  83.     0 << ANFRACSIZE,
  84. };
  85.  
  86. SHORT XVel[] = 
  87. {
  88. /* fish's */
  89.     4 << ANFRACSIZE,
  90. };
  91.  
  92. SHORT YVel[] = 
  93. {
  94. /* fish's */
  95.     0 << ANFRACSIZE,
  96. };
  97.  
  98. /* !!! define an animCRoutine here */
  99.  
  100. /* !!! define an animORoutine here */
  101.  
  102. fishMRoutine(anOb)
  103. struct AnimOb *anOb;
  104. {
  105.     register struct AnimComp *acptr, *seqptr;
  106.  
  107.     acptr = anOb->HeadComp;
  108.     while (acptr)
  109.         {
  110.         seqptr = acptr;
  111.         do
  112.             {
  113.             if (seqptr->AnimBob->BobVSprite->Flags & GELGONE)
  114.                 {
  115.                 seqptr->AnimBob->BobVSprite->Flags &= ~GELGONE;
  116.                 fishOb.AnX = 0 << ANFRACSIZE;
  117.                 }
  118.             seqptr = seqptr->NextSeq;
  119.             }
  120.         while (seqptr != acptr && (seqptr));
  121.         acptr = acptr->NextComp;
  122.         }
  123. }
  124.  
  125. fish1Routine(comp)
  126. struct AnimComp *comp;
  127. {
  128.     /* if (fish1Comp.Timer == 1)
  129.         fishOb.AnX += (87 << ANFRACSIZE); */
  130.  
  131.     return(TRUE);
  132. }
  133.  
  134. short startFlag = 4;
  135.  
  136. animinit(animKey,vp, wR)
  137. struct AnimOb **animKey;
  138. struct ViewPort *vp;
  139. struct RastPort *wR;
  140. {
  141.     SHORT i;
  142.  
  143.     Index = 0;
  144.     fishOb.XVel = XVel[0];
  145.     fishOb.YVel = YVel[0];
  146.  
  147.     fishOb.HeadComp = &fish1Comp;
  148.  
  149.     fish1Bob.Before = NULL;
  150.     fish1Bob.After = NULL;
  151.  
  152.     InitAnimate(animKey);
  153.  
  154.     extrainit(&fishOb, TRUE, wR);   
  155.     AddAnimOb(&fishOb, animKey,wR);
  156.  
  157.     for (i = 0; i < 8; i++)
  158.         SetRGB4(vp,i ,
  159.             (color92[i] >> 8) & 0x00F, 
  160.             (color92[i] >> 4) & 0x00F, 
  161.             (color92[i] >> 0) & 0x00F); 
  162.     
  163. }
  164.  
  165. extrainit(animKey, addFlag,wR)
  166. struct AnimOb *animKey;
  167. BOOL addFlag;
  168. struct RastPort *wR;
  169. {
  170.     struct AnimOb *anOb;
  171.     struct AnimComp *acptr;
  172.     struct AnimComp *seqptr, *sseqptr;
  173.     struct Bob *bptr;
  174.     struct Sprite *sptr;
  175.     short i, depth, sw, sh;
  176.     UBYTE *iptr, *i2ptr, *pptr;
  177.     short ibufsize, pbufsize;
  178.  
  179.  
  180. /* animOb inits */
  181.  
  182.     anOb = animKey;
  183.     anOb->AnX = ALLSTART << ANFRACSIZE;
  184.     anOb->AnY = 0;
  185.  
  186.     anOb->XAccel = 0;
  187.     anOb->YAccel = 0;
  188.     anOb->Clock = 0;
  189.  
  190.     acptr = anOb->HeadComp;
  191.     while (acptr)
  192.         {
  193.         acptr->AnimBob->BobVSprite->X =
  194.         (anOb->AnX + xtranslations[Index] + ANIMHALF) >> ANFRACSIZE;
  195.         acptr->AnimBob->BobVSprite->Y =
  196.         (anOb->AnY + ytranslations[Index] + ANIMHALF) >> ANFRACSIZE;
  197.         sseqptr = seqptr = acptr;
  198.         do
  199.             {
  200.             seqptr->AnimBob->Flags = BOBISCOMP;
  201.             seqptr->AnimBob->BobVSprite->Flags = SAVEBACK|OVERLAY;
  202.             seqptr->TimeSet = timers[Index];
  203.             seqptr->XTrans = xtranslations[Index];
  204.             seqptr->YTrans = ytranslations[Index];
  205.             seqptr->AnimBob->BobVSprite->PlaneOnOff= 0x10;
  206.             Index++;
  207.             seqptr = seqptr->NextSeq;
  208.             }
  209.         while (seqptr != sseqptr && (seqptr));
  210.         acptr = acptr->NextComp;
  211.         }
  212.  
  213.     if (! (GetGBuffers(anOb, wR, TRUE)))
  214.     {  
  215.         exit(3);
  216.     }
  217.     InitGMasks(anOb);
  218. }
  219.  
  220. free_anim_obj(RPort)
  221. struct RastPort *RPort;
  222. {
  223.  
  224.     FreeGBuffers(&fishOb,RPort,TRUE);
  225.  
  226.  
  227.