home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Glypha II 1.21 / source / Code ƒ / E-Enemies.p < prev    next >
Encoding:
Text File  |  1991-05-18  |  22.8 KB  |  812 lines  |  [TEXT/PJMM]

  1. unit Enemies;
  2.  
  3. interface
  4.     uses
  5.         Palettes, Sound, Globals, GameUtils;
  6.  
  7.     procedure UpdateEye;
  8.     procedure UpdateTheHand;
  9.     procedure RetractTheHand;
  10.     procedure EnemyHitAStone (whichStone: Rect; which: Integer);
  11.     procedure DoEnemyPlacement (who: Integer);
  12.     procedure DeathToTheBeast (who: Integer);
  13.     procedure PlayerBeastCollision (who: Integer);
  14.     procedure HandleTheEnemies;
  15.  
  16. implementation
  17.  
  18. {=================================}
  19.  
  20.     procedure MoveEye;
  21.     begin
  22.         if (thePlayer.otherState) then
  23.             Exit(MoveEye);
  24.         with theEye do
  25.             begin
  26.                 if thePlayer.dest.left < dest.left then
  27.                     begin
  28.                         dest.left := dest.left - 4;
  29.                         dest.right := dest.right - 4;
  30.                     end
  31.                 else
  32.                     begin
  33.                         dest.left := dest.left + 4;
  34.                         dest.right := dest.right + 4;
  35.                     end;
  36.                 if thePlayer.dest.top < dest.top then
  37.                     begin
  38.                         dest.top := dest.top - 2;
  39.                         dest.bottom := dest.bottom - 2;
  40.                     end
  41.                 else
  42.                     begin
  43.                         dest.top := dest.top + 2;
  44.                         dest.bottom := dest.bottom + 2;
  45.                     end;
  46.             end;
  47.     end;
  48.  
  49. {=================================}
  50.  
  51.     procedure UpdateEye;
  52.         var
  53.             dummyRect, tempRect: Rect;
  54.     begin
  55.         with theEye do
  56.             begin
  57.                 case mode of
  58.                     1..3: 
  59.                         begin
  60.                             mode := mode + 1;
  61.                             otherMode := 0;
  62.                             StrikeLightning(tempInt);
  63.                         end;
  64.                     4..6: 
  65.                         begin
  66.                             mode := mode + 1;
  67.                             otherMode := 1;
  68.                         end;
  69.                     7..9: 
  70.                         begin
  71.                             mode := mode + 1;
  72.                             otherMode := 2;
  73.                         end;
  74.                     10..12: 
  75.                         begin
  76.                             mode := mode + 1;
  77.                             otherMode := 3;
  78.                         end;
  79.                     13..230: 
  80.                         begin
  81.                             mode := mode + 1;
  82.                             otherMode := 4;
  83.                             MoveEye;
  84.                         end;
  85.                     231..235: 
  86.                         begin
  87.                             mode := mode + 1;
  88.                             otherMode := 3;
  89.                             MoveEye;
  90.                         end;
  91.                     236..240: 
  92.                         begin
  93.                             mode := mode + 1;
  94.                             otherMode := 2;
  95.                             MoveEye;
  96.                         end;
  97.                     241..245: 
  98.                         begin
  99.                             mode := mode + 1;
  100.                             otherMode := 1;
  101.                             MoveEye;
  102.                         end;
  103.                     246..255: 
  104.                         begin
  105.                             mode := mode + 1;
  106.                             otherMode := 0;
  107.                             MoveEye;
  108.                         end;
  109.                     256..260: 
  110.                         begin
  111.                             mode := mode + 1;
  112.                             otherMode := 1;
  113.                             MoveEye;
  114.                         end;
  115.                     261..265: 
  116.                         begin
  117.                             mode := mode + 1;
  118.                             otherMode := 2;
  119.                             MoveEye;
  120.                         end;
  121.                     266..270: 
  122.                         begin
  123.                             mode := mode + 1;
  124.                             otherMode := 3;
  125.                             MoveEye;
  126.                         end;
  127.                     271: 
  128.                         begin
  129.                             mode := 81;
  130.                         end;
  131.                     272..275:                         {Here the eye is closing for good        }
  132.                         begin                                {The eye will never even get to a        }
  133.                             mode := mode + 1;    {mode >= 272 unless the player            }
  134.                             otherMode := 3;        {manages to hit the eye while it is    }
  135.                             MoveEye;                    {closing.                                                        }
  136.                         end;
  137.                     276..280: 
  138.                         begin
  139.                             mode := mode + 1;
  140.                             otherMode := 2;
  141.                             MoveEye;
  142.                         end;
  143.                     281..285: 
  144.                         begin
  145.                             mode := mode + 1;
  146.                             otherMode := 1;
  147.                             MoveEye;
  148.                         end;
  149.                     286..290: 
  150.                         begin
  151.                             mode := mode + 1;
  152.                             otherMode := 0;
  153.                             MoveEye;
  154.                         end;
  155.                     291: 
  156.                         begin
  157.                             UnionRect(oldDest, dest, wholeRect);
  158.                             CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, mainWndo^.portBits, wholeRect, wholeRect, srcCopy, playRgn);
  159.                             mode := (levelOn * 10) - 300;
  160.                             if mode > -50 then
  161.                                 mode := -50;
  162.                             dest := eyeRects[4];
  163.                             CenterZeroRect(dest);
  164.                             if (DoRandom(2) = 0) then
  165.                                 OffsetRect(dest, 320, upperEyeHeight)
  166.                             else
  167.                                 OffsetRect(dest, 320, lowerEyeHeight);
  168.                             oldDest := dest;
  169.                         end;
  170.  
  171.                     otherwise
  172.                         begin
  173.                             mode := mode + 1;
  174.                             if (mode = 0) then
  175.                                 begin
  176.                                     DoTheSound('lightning.snd', highPriority);
  177.                                     dest := eyeRects[4];
  178.                                     CenterZeroRect(dest);
  179.                                     if (DoRandom(2) = 0) then
  180.                                         begin
  181.                                             OffsetRect(dest, 320, upperEyeHeight);
  182.                                             StrikeLightning(upperEye);
  183.                                             tempInt := upperEye;
  184.                                         end
  185.                                     else
  186.                                         begin
  187.                                             OffsetRect(dest, 320, lowerEyeHeight);
  188.                                             StrikeLightning(lowerEye);
  189.                                             tempInt := lowerEye;
  190.                                         end;
  191.                                     oldDest := dest;
  192.                                 end;
  193.                             Exit(UpdateEye);
  194.                         end;
  195.                 end;
  196.                 tempRect := dest;
  197.                 InsetRect(tempRect, 10, 5);
  198.                 if SectRect(tempRect, thePlayer.dest, dummyRect) then
  199.                     begin
  200.                         if otherMode = 4 then                {The player is DEAD!            }
  201.                             begin
  202.                                 thePlayer.otherState := TRUE;
  203.                                 DoTheSound('bird.snd', highPriority);
  204.                             end
  205.                         else if (mode <> 291) then    {The player killed the eye!!!    }
  206.                             begin
  207.                                 DoTheSound('bonus.snd', highPriority);
  208.                                 score := score + 2000;
  209.                                 ShowScore;
  210.                                 CheckExtraMortal;
  211.                                 mode := 291;
  212.                                 UnionRect(oldDest, dest, wholeRect);
  213.                                 CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, mainWndo^.portBits, wholeRect, wholeRect, srcCopy, playRgn);
  214.                             end;
  215.                     end;
  216.             end;
  217.     end;
  218.  
  219. {=================================}
  220.  
  221.     procedure UpdateTheHand;
  222.         const
  223.             handWidth = 64;
  224.             handHeight = 57;
  225.             noLegDelta = 10;
  226.         var
  227.             dummyRect, tempRect: Rect;
  228.     begin
  229.         if ((levelOn < 3) or (stonesSliding)) then
  230.             Exit(UpdateTheHand);
  231.         with theHand do
  232.             begin
  233.                 state := TRUE;
  234.                 if mode = 0 then
  235.                     begin
  236.                         if (thePlayer.dest.left < dest.left) then
  237.                             begin
  238.                                 dest.left := dest.left - 6;
  239.                                 dest.right := dest.right - 6;
  240.                                 if (dest.left < handLeft) then
  241.                                     begin
  242.                                         dest.left := handLeft;
  243.                                         dest.right := dest.left + handWidth;
  244.                                     end;
  245.                             end
  246.                         else
  247.                             begin
  248.                                 dest.left := dest.left + 6;
  249.                                 dest.right := dest.right + 6;
  250.                             end;
  251.  
  252.                         if (thePlayer.dest.bottom < dest.top) then
  253.                             begin
  254.                                 dest.top := dest.top - 3;
  255.                                 dest.bottom := dest.bottom - 3;
  256.                                 if (dest.top < handTop) then
  257.                                     begin
  258.                                         dest.top := handTop;
  259.                                         dest.bottom := dest.top + handHeight;
  260.                                     end;
  261.                             end
  262.                         else
  263.                             begin
  264.                                 dest.top := dest.top + 1;
  265.                                 dest.bottom := dest.bottom + 1;
  266.                             end;
  267.  
  268.                         tempRect := dest;
  269.                         tempRect.right := tempRect.left + 40;
  270.                         if SectRect(tempRect, thePlayer.dest, dummyRect) and (thePlayer.dest.left < dest.left + 40) then
  271.                             begin
  272.                                 DoTheSound('bird.snd', highPriority);
  273.                                 mode := 1;
  274.                                 OffsetRect(thePlayer.dest, dest.left - thePlayer.dest.left - (thePlayer.facing * 25), dest.top - thePlayer.dest.bottom + noLegDelta);
  275.                                 thePlayer.horiVel := 0;
  276.                                 thePlayer.vertVel := 0;
  277.                                 oldDirection := thePlayer.facing;
  278.                             end;
  279.                     end
  280.                 else
  281.                     begin
  282.                         OffsetRect(thePlayer.dest, (oldDirection - thePlayer.facing) * 25 - thePlayer.horiVel, -thePlayer.vertVel);
  283.                         if (thePlayer.vertVel < 0) and (DoRandom(levelOn div 5) = 0) then
  284.                             begin
  285.                                 dest.top := dest.top - 2;
  286.                                 dest.bottom := dest.bottom - 2;
  287.                                 thePlayer.dest.top := thePlayer.dest.top - 2;
  288.                                 thePlayer.dest.bottom := thePlayer.dest.bottom - 2;
  289.                             end
  290.                         else if (thePlayer.vertVel >= 0) then
  291.                             begin
  292.                                 dest.top := dest.top + 1;
  293.                                 dest.bottom := dest.bottom + 1;
  294.                                 thePlayer.dest.top := thePlayer.dest.top + 1;
  295.                                 thePlayer.dest.bottom := thePlayer.dest.bottom + 1;
  296.                             end;
  297.                         thePlayer.horiVel := 0;
  298.                         thePlayer.vertVel := 0;
  299.                         oldDirection := thePlayer.facing;
  300.                     end;
  301.                 DrawHand;
  302.                 oldDest := dest;
  303.             end;
  304.     end;
  305.  
  306. {=================================}
  307.  
  308.     procedure RetractTheHand;
  309.     begin
  310.         with theHand do
  311.             begin
  312.                 mode := 0;
  313.                 dest.top := dest.top + 1;
  314.                 dest.bottom := dest.bottom + 1;
  315.                 if (dest.top > handBottom) then
  316.                     state := FALSE;
  317.                 DrawHand;
  318.                 oldDest := dest;
  319.             end;
  320.     end;
  321.  
  322. {=================================}
  323.  
  324.     procedure EnemyHitAStone;
  325.         var
  326.             hori, vert: Integer;
  327.     begin
  328.         with theEnemies[which] do
  329.             begin
  330.                 if (horiVel > 0) then
  331.                     begin
  332.                         if (dest.left < whichStone.left) then    {hit the edge}
  333.                             begin
  334.                                 dest.left := dest.left + whichStone.left - whichStone.right;
  335.                                 dest.right := dest.right + whichStone.left - whichStone.right;
  336.                                 horiVel := impacted[horiVel];
  337.                             end
  338.                         else
  339.                             begin
  340.                                 if (vertVel < 0) then        {hit coming up}
  341.                                     begin
  342.                                         vertVel := impacted[vertVel];
  343.                                         dest.bottom := dest.bottom + whichStone.bottom - dest.top;
  344.                                         dest.top := dest.top + whichStone.bottom - dest.top;
  345.                                     end
  346.                                 else
  347.                                     begin
  348.                                         if (mode < -1) then
  349.                                             begin
  350.                                                 horiVel := (horiVel * 2) div 3;
  351.                                                 vertVel := impacted[vertVel];
  352.                                                 if (ABS(vertVel) < 3) then
  353.                                                     begin
  354.                                                         vertVel := 0;
  355.                                                         horiVel := 0;
  356.                                                         otherState := TRUE;
  357.                                                     end;
  358.                                                 dest.top := dest.top + whichStone.top - dest.bottom;
  359.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom;
  360.                                                 Exit(EnemyHitAStone);
  361.                                             end;
  362.                                         if (vertVel < 4) or (dest.right > whichStone.right) then
  363.                                             begin
  364.                                                 vertVel := -3;
  365.                                                 dest.top := dest.top + whichStone.top - dest.bottom;
  366.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom;
  367.                                             end
  368.                                         else
  369.                                             begin
  370.                                                 vertVel := 0;
  371.                                                 dest.top := dest.top + whichStone.top - dest.bottom - 10;
  372.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom - 10;
  373.                                                 mode := 1;
  374.                                                 hori := dest.left;
  375.                                                 vert := dest.top;
  376.                                                 SetRect(dest, 0, 0, 41, 42);
  377.                                                 dest.top := dest.top + vert;
  378.                                                 dest.bottom := dest.bottom + vert;
  379.                                                 dest.left := dest.left + hori;
  380.                                                 dest.right := dest.right + hori;
  381.                                             end;
  382.                                     end;
  383.                             end;
  384.                     end
  385.                 else
  386.                     begin
  387.                         if (dest.right > whichStone.right) then    {hit the edge}
  388.                             begin
  389.                                 dest.left := dest.left + whichStone.right - whichStone.left;
  390.                                 dest.right := dest.right + whichStone.right - whichStone.left;
  391.                                 horiVel := impacted[horiVel];
  392.                             end
  393.                         else
  394.                             begin
  395.                                 if (vertVel < 0) then        {hit coming up}
  396.                                     begin
  397.                                         vertVel := impacted[vertVel];
  398.                                         dest.bottom := dest.bottom + whichStone.bottom - dest.top;
  399.                                         dest.top := dest.top + whichStone.bottom - dest.top;
  400.                                     end
  401.                                 else
  402.                                     begin
  403.                                         if (mode < -1) then
  404.                                             begin
  405.                                                 horiVel := (horiVel * 2) div 3;
  406.                                                 vertVel := impacted[vertVel];
  407.                                                 if (ABS(vertVel) < 3) then
  408.                                                     begin
  409.                                                         horiVel := 0;
  410.                                                         vertVel := 0;
  411.                                                         otherState := TRUE;
  412.                                                     end;
  413.                                                 dest.top := dest.top + whichStone.top - dest.bottom;
  414.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom;
  415.                                                 Exit(EnemyHitAStone);
  416.                                             end;
  417.                                         if (vertVel < 4) or (dest.left < whichStone.left) then
  418.                                             begin
  419.                                                 vertVel := -3;
  420.                                                 dest.top := dest.top + whichStone.top - dest.bottom;
  421.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom;
  422.                                             end
  423.                                         else
  424.                                             begin
  425.                                                 vertVel := 0;
  426.                                                 dest.top := dest.top + whichStone.top - dest.bottom - 10;
  427.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom - 10;
  428.                                                 mode := 1;
  429.                                                 hori := dest.left;
  430.                                                 vert := dest.top;
  431.                                                 SetRect(dest, 0, 0, 41, 42);
  432.                                                 dest.top := dest.top + vert;
  433.                                                 dest.bottom := dest.bottom + vert;
  434.                                                 dest.left := dest.left + hori;
  435.                                                 dest.right := dest.right + hori;
  436.                                             end;
  437.                                     end;
  438.                             end;
  439.                     end;
  440.             end;
  441.     end;
  442.  
  443. {=================================}
  444.  
  445.     procedure DoEnemyPlacement;
  446.         var
  447.             aNumber, anotherNumber: Integer;
  448.     begin
  449.         with theEnemies[who] do
  450.             begin
  451.                 otherState := FALSE;
  452.                 facing := DoRandom(2);
  453.                 aNumber := DoRandom(2);
  454.                 if (((levelOn + 1) div 5) = ((levelOn + 1) / 5)) then
  455.                     aNumber := 1;
  456.                 anotherNumber := DoRandom(102);
  457.                 if facing = 0 then
  458.                     begin
  459.                         if aNumber = 0 then
  460.                             begin
  461.                                 dest := enemyRects[0, 0, 0];
  462.                                 OffsetRect(dest, -dest.left, -dest.bottom);
  463.                                 OffsetRect(dest, anotherNumber, tombRects[3].top + 1);
  464.                                 dest.top := dest.bottom;
  465.                             end
  466.                         else
  467.                             begin
  468.                                 dest := enemyRects[0, 0, 0];
  469.                                 OffsetRect(dest, -dest.left, -dest.bottom);
  470.                                 OffsetRect(dest, anotherNumber, tombRects[1].top + 1);
  471.                                 dest.top := dest.bottom;
  472.                             end;
  473.                     end
  474.                 else
  475.                     begin
  476.                         if aNumber = 0 then
  477.                             begin
  478.                                 dest := enemyRects[0, 0, 0];
  479.                                 OffsetRect(dest, -dest.left, -dest.bottom);
  480.                                 OffsetRect(dest, 640 - 150 + anotherNumber, tombRects[4].top + 1);
  481.                                 dest.top := dest.bottom;
  482.                             end
  483.                         else
  484.                             begin
  485.                                 dest := enemyRects[0, 0, 0];
  486.                                 OffsetRect(dest, -dest.left, -dest.bottom);
  487.                                 OffsetRect(dest, 640 - 150 + anotherNumber, tombRects[2].top + 1);
  488.                                 dest.top := dest.bottom;
  489.                             end;
  490.                     end;
  491.                 oldDest := dest;
  492.             end;
  493.     end;
  494. {=================================}
  495.  
  496.     procedure DeathToTheBeast;
  497.         var
  498.             aNumber: Integer;
  499.             tempRect: Rect;
  500.     begin
  501.         with theEnemies[who] do
  502.             begin
  503.                 UnionRect(oldDest, dest, wholeRect);
  504.                 CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, mainWndo^.portBits, wholeRect, wholeRect, srcCopy, playRgn);
  505.                 mode := DoRandom(kEnemyModeRange) + kEnemyModeMinumum;
  506.                 vertVel := 0;
  507.                 horiVel := 0;
  508.                 DoEnemyPlacement(who);
  509.  
  510.                 aNumber := DoRandom(levelOn);    {What type of sphinx?  O, 1 or 2?  Well, on level 1,}
  511.                 if (aNumber > 20) then                {there is a 0% chance that a random # between 0 &}
  512.                     otherMode := 2                            {0 will be greater than 20...so, no tough sphinx.}
  513.                 else                                                    {But on level 30, aNumber will be a random number}
  514.                     begin                                                {between 0 and 29.  That gives us almost a 33%}
  515.                         if (aNumber > 5) then        {chance that it will be a sphinx 2, if not a sphinx 2,}
  516.                             otherMode := 1                    {(not >20) then a good 50% chance that aNumber>10}
  517.                         else                                            {(11 to 20) and thus a sphinx 1.  Note: there is}
  518.                             otherMode := 0;                    {ALWAYS a CHANCE of the easiest sphinx 0, but it}
  519.                     end;                                                {gets increasingly unlikely as the player goes on.}
  520.  
  521.                 if (state) and (otherMode > 0) then
  522.                     begin
  523.                         otherMode := otherMode - 1;
  524.                         state := FALSE;
  525.                     end;
  526.                 beastsKilled := beastsKilled + 1;
  527.                 beastsActive := beastsActive - 1;
  528.                 if (beastsKilled >= totalToKill) then
  529.                     begin
  530.                         onward := TRUE;
  531.                     end;
  532.             end;
  533.     end;
  534.  
  535. {=================================}
  536.  
  537.     procedure PlayerBeastCollision;
  538.         var
  539.             hori, vert: Integer;
  540.             tempRect: Rect;
  541.     begin
  542.         with theEnemies[who] do
  543.             begin
  544.                 if (mode < 0) then    {You hit the enemy while in egg form!    }
  545.                     begin
  546.                         DoTheSound('boom1.snd', highPriority);
  547.                         DeathToTheBeast(who);                        {So, get the beast killed and reset        }
  548.                         score := score + 500;                        {That's 500 points for the player            }
  549.                         ShowScore;
  550.                         CheckExtraMortal;
  551.                         Exit(PlayerBeastCollision);            {All we need here                            }
  552.                     end;
  553.                 if ((thePlayer.dest.top > dest.top + 1) and (not thePlayer.otherState) and (mode > -1)) then
  554.                     begin                                                            {The beast killed you!    }
  555.                         thePlayer.otherState := TRUE;        {The player is dead        }
  556.                         DoTheSound('boom2.snd', highPriority);    {Make that death sound    }
  557.                     end
  558.                 else
  559.                     begin
  560.                         if (dest.top > thePlayer.dest.top + 2) then
  561.                             begin                                                    {The player killed the beast!!!            }
  562.                                 score := score + 500 + (500 * otherMode);    {Score based on what sphinx model    }
  563.                                 ShowScore;
  564.                                 CheckExtraMortal;
  565.                                 if (otherMode < 2) then
  566.                                     begin
  567.                                         otherMode := otherMode + 1;        {Bump up the sphinx model        }
  568.                                         state := TRUE;                                {Let program remember this    }
  569.                                     end;
  570.                                 DoTheSound('boom2.snd', highPriority);        {Make that big boom sound        }
  571.                                 mode := DoRandom(200) - 350;            {Enemy becomes an egg                }
  572.                                 hori := dest.left;
  573.                                 vert := dest.top;
  574.                                 SetRect(dest, 0, 0, 24, 24);
  575.                                 if (vertVel <> 0) then
  576.                                     begin
  577.                                         dest.top := dest.top + vert + 24;
  578.                                         dest.bottom := dest.bottom + vert + 24;
  579.                                         dest.left := dest.left + hori;
  580.                                         dest.right := dest.right + hori;
  581.                                     end
  582.                                 else
  583.                                     begin
  584.                                         dest.top := dest.top + vert;
  585.                                         dest.bottom := dest.bottom + vert;
  586.                                         dest.left := dest.left + hori;
  587.                                         dest.right := dest.right + hori;
  588.                                     end;
  589.                             end
  590.                         else
  591.                             begin                                                            {close - they bounced off each other    }
  592.                                 DoTheSound('screech.snd', lowPriority);                        {Make that screeching sound            }
  593.                                 horiVel := impacted[horiVel];
  594.                                 thePlayer.horiVel := impacted[thePlayer.horiVel];
  595.                             end;
  596.                     end;
  597.             end;
  598.     end;
  599.  
  600. {=================================}
  601.  
  602.     procedure HandleTheEnemies;
  603.         var
  604.             onLand: Boolean;
  605.             index, loop, hori, vert: Integer;
  606.             dummyLong: LongInt;
  607.             tempRect, dummyRect: Rect;
  608.     begin
  609.         for loop := 1 to numberOfEnemies do
  610.             with theEnemies[loop] do
  611.                 begin
  612.                     case mode of
  613.                         -600..-2:    {egg stage - hasn't hatched yet}
  614.                             begin
  615.                                 mode := mode + 1;
  616.                                 if (mode = -1) then
  617.                                     DoTheSound('spawn.snd', highPriority);
  618.                                 if (otherState) then                    {Has the egg stopped falling?}
  619.                                     begin
  620.                                         horiVel := horiVel * 2 div 3;
  621.                                         onLand := FALSE;
  622.                                         tempRect := dest;
  623.                                         tempRect.left := tempRect.left + 10;
  624.                                         tempRect.right := tempRect.right - 10;
  625.                                         tempRect.top := tempRect.top + 2;
  626.                                         tempRect.bottom := tempRect.bottom + 2;
  627.  
  628.                                         for index := startStone to numberOfStones do
  629.                                             if (SectRect(tombRects[index], tempRect, dummyRect)) then
  630.                                                 onLand := TRUE;
  631.                                         if (not onLand) then
  632.                                             begin
  633.                                                 otherState := FALSE;
  634.                                                 vertVel := fallAmount;
  635.                                             end;
  636.                                     end
  637.                                 else
  638.                                     begin
  639.                                         if (vertVel < (maxFall div 3)) then
  640.                                             vertVel := vertVel + fallAmount;
  641.                                         for index := startStone to numberOfStones do
  642.                                             if SectRect(dest, tombRects[index], dummyRect) then
  643.                                                 EnemyHitAStone(dummyRect, loop);
  644.                                     end;
  645.                                 dest.left := dest.left + horiVel;
  646.                                 dest.right := dest.right + horiVel;
  647.                                 dest.top := dest.top + vertVel;
  648.                                 dest.bottom := dest.bottom + vertVel;
  649.                             end;
  650.  
  651.                         -1:         {egg hatches!!!}
  652.                             begin
  653.                                 dest.top := dest.top + growRate;
  654.                                 if (dest.top >= dest.bottom) then
  655.                                     begin
  656.                                         dest.top := dest.bottom;
  657.                                         dest.left := dest.left - 12;
  658.                                         dest.right := dest.left + 48;
  659.                                         otherState := FALSE;
  660.                                         mode := 6;
  661.                                     end;
  662.                             end;
  663.  
  664.                         0..2:    {if running along the ground}
  665.                             begin
  666.                                 onLand := FALSE;                                    {First, we assume the enemy is}
  667.                                 tempRect.left := dest.left + 17;    {no longer on land.  Then we test}
  668.                                 tempRect.right := dest.right - 17;{the enemies rect to see if it is}
  669.                                 tempRect.top := dest.top + 2;            {intersecting the ground.}
  670.                                 tempRect.bottom := dest.bottom + 2;
  671.  
  672.                                 for index := startStone to numberOfStones do
  673.                                     if (SectRect(tombRects[index], tempRect, dummyRect)) then
  674.                                         onLand := TRUE;                    {Yes, enemy is still on land.}
  675.                                 if (not onLand) or (DoRandom(6) = 0) then
  676.                                     begin                                            {If enemy is'nt still on the ledge...}
  677.                                         mode := 4;
  678.                                         dest.right := dest.left + 67;
  679.                                         dest.bottom := dest.top + 36;
  680.                                         vertVel := fallAmount;
  681.                                     end
  682.                                 else                {in fact, we're on solid ground after all}
  683.                                     begin
  684.                                         horiVel := running[horiVel, facing, 0];
  685.                                         mode := running[horiVel, facing, 1];
  686.                                     end;
  687.  
  688.                                 dest.left := dest.left + horiVel;
  689.                                 dest.right := dest.right + horiVel;
  690.                                 dest.top := dest.top + vertVel;
  691.                                 dest.bottom := dest.bottom + vertVel;
  692.                             end;
  693.  
  694.                         4..5:                    {else, the dude is in the air}
  695.                             begin
  696.                                 horiVel := gliding[horiVel, facing];
  697.  
  698.                                 if ((thePlayer.dest.top > dest.top - 150) and (thePlayer.dest.top < dest.top + 20)) and (not thePlayer.otherState) then
  699.                                     begin            {the dude's gonna flap and turn to face you}
  700.                                         mode := 5;
  701.                                         vertVel := vertVel + enemyLift[otherMode];
  702.                                         if (thePlayer.dest.left < dest.left) then
  703.                                             facing := 1
  704.                                         else
  705.                                             facing := 0;
  706.                                     end
  707.                                 else
  708.                                     begin
  709.                                         if ((thePlayer.dest.top > dest.top + 20) and (not thePlayer.otherState) and (vertVel < maxFall)) then
  710.                                             begin
  711.                                                 vertVel := vertVel + fallAmount;
  712.                                             end
  713.                                         else
  714.                                             begin
  715.                                                 if (vertVel > 8) or (dest.bottom > 290) or (DoRandom(4) = 0) then
  716.                                                     begin            {the dude's also gonna flap}
  717.                                                         mode := 5;
  718.                                                         vertVel := vertVel + enemyLift[otherMode];
  719.                                                     end
  720.                                                 else                {the dude instead is just gliding}
  721.                                                     begin
  722.                                                         mode := 4;
  723.                                                         if (vertVel < maxFall) then
  724.                                                             vertVel := vertVel + fallAmount;
  725.                                                     end;
  726.                                             end;
  727.                                     end;
  728.  
  729.                                 dest.left := dest.left + horiVel;
  730.                                 dest.right := dest.right + horiVel;
  731.                                 dest.top := dest.top + vertVel;
  732.                                 dest.bottom := dest.bottom + vertVel;
  733.  
  734.                                 for index := startStone to numberOfStones do
  735.                                     begin
  736.                                         if SectRect(dest, tombRects[index], dummyRect) then
  737.                                             EnemyHitAStone(dummyRect, loop);
  738.                                     end;
  739.                             end;
  740.  
  741.                         6: 
  742.                             begin
  743.                                 dest.top := dest.top - growRate;
  744.                                 if ((dest.bottom - dest.top) >= 40) then
  745.                                     begin
  746.                                         dest.top := dest.bottom - 40;
  747.                                         mode := 0;
  748.                                     end;
  749.                             end;
  750.  
  751.                         7: 
  752.                             begin
  753.                                 if (beastsKilled + beastsActive) < totalToKill then
  754.                                     begin
  755.                                         DoTheSound('spawn.snd', highPriority);
  756.                                         beastsActive := beastsActive + 1;
  757.                                         mode := 6;
  758.                                     end
  759.                                 else
  760.                                     mode := 500;
  761.                             end;
  762.  
  763.                         8..500: 
  764.                             mode := mode - 1;
  765.  
  766.                         otherwise
  767.                             begin
  768.                                 mode := mode - 1;
  769.                             end;
  770.                     end;                    {end - case Mode}
  771.  
  772.                     if ((not SectRect(dest, playRect, dummyRect)) and (mode <> 6)) and (mode <> -1) then
  773.                         begin
  774.                             if (dest.top > playRect.bottom) then
  775.                                 begin
  776.                                     DoTheSound('drip.snd', highPriority);
  777.                                     DeathToTheBeast(loop);
  778.                                 end
  779.                             else if (dest.top <= 0) then
  780.                                 begin
  781.                                     vertVel := impacted[vertVel];
  782.                                     dest.bottom := dest.bottom - dest.top;
  783.                                     dest.top := 0;
  784.                                 end;
  785.                             if (dest.right < playRect.left) then        {Wraparound routines    }
  786.                                 begin
  787.                                     CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, mainWndo^.portBits, oldDest, oldDest, srcCopy, playRgn);
  788.                                     dest.right := dest.right + 640;
  789.                                     dest.left := dest.left + 640;
  790.                                     oldDest := dest;
  791.                                 end
  792.                             else if (dest.left > playRect.right) then
  793.                                 begin
  794.                                     CopyBits(BitMapPtr(virginCPtr^.portPixMap^)^, mainWndo^.portBits, oldDest, oldDest, srcCopy, playRgn);
  795.                                     dest.left := dest.left - 640;
  796.                                     dest.right := dest.right - 640;
  797.                                     oldDest := dest;
  798.                                 end;
  799.                         end;        {if not SectRect}
  800.  
  801.                     tempRect := dest;
  802.                     if (mode >= 0) then
  803.                         InsetRect(tempRect, 16, 6);
  804.                     if (SectRect(tempRect, thePlayer.dest, dummyRect) and (not thePlayer.otherState)) then
  805.                         PlayerBeastCollision(loop);
  806.  
  807.                 end;                    {end - for loop}
  808.     end;
  809.  
  810. {=================================}
  811.  
  812. end.