home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / LostSheep.dxr / 00012_Sheepy.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  4.5 KB  |  136 lines

  1. property spriteNum, pMyAngle, h, v, pSheepDirection, pSheepSpeed, pLocH, pLocV, pSheepDistance, pSheepRotation, pWait4Step, pSheepBaah, pSheepAlive
  2. global gLevel
  3.  
  4. on beginSprite me
  5.   pSheepAlive = 1
  6.   pLocH = sprite(spriteNum).locH
  7.   pLocV = sprite(spriteNum).locV
  8.   pSheepSpeed = 0
  9.   pSheepDirection = 0.0
  10.   pSheepDistance = 0.0
  11.   pSheepRotation = 0.0
  12.   pWait4Step = 0
  13.   pSheepBaah = 0
  14. end
  15.  
  16. on exitFrame me
  17.   if pSheepAlive = 1 then
  18.     pSheepDistance = getDistance(sprite(spriteNum).locH, sprite(spriteNum).locV, mouseH(), mouseV())
  19.     if pSheepDistance > 180 then
  20.       pSheepSpeed = 0
  21.     else
  22.       pSheepDistance = getDistance(sprite(spriteNum).locH, sprite(spriteNum).locV, mouseH(), mouseV())
  23.       pSheepSpeed = (180 - pSheepDistance) / 20.0
  24.       pSheepDirection = getAngle(sprite(spriteNum).locH, sprite(spriteNum).locV, mouseH(), mouseV())
  25.       pSheepRotation = 360 - getAngle(mouseH(), mouseV(), sprite(spriteNum).locH, sprite(spriteNum).locV)
  26.       sprite(spriteNum).rotation = pSheepRotation
  27.       SheepMove()
  28.     end if
  29.   end if
  30. end
  31.  
  32. on SheepMove
  33.   pMyAngle = pSheepDirection * PI / 180.0
  34.   h = sin(pMyAngle) * pSheepSpeed
  35.   v = cos(pMyAngle) * pSheepSpeed
  36.   pLocH = pLocH + h
  37.   pLocV = pLocV + v
  38.   sprite(32).loc = point(pLocH, pLocV)
  39.   sprite(32).rotation = pSheepRotation
  40.   updateStage()
  41.   ObjectCollision()
  42.   sprite(spriteNum).loc = point(pLocH, pLocV)
  43. end
  44.  
  45. on ObjectCollision
  46.   if gLevel = 1 then
  47.     if sprite(32).intersects(5) or sprite(32).intersects(12) or sprite(32).intersects(11) or sprite(32).intersects(10) or sprite(32).intersects(3) then
  48.       pLocH = pLocH - h
  49.       pLocV = pLocV - v
  50.     else
  51.       sheepSounds()
  52.       SheepCounter()
  53.     end if
  54.   else
  55.     if gLevel = 2 then
  56.       if sprite(32).intersects(5) or sprite(32).intersects(13) or sprite(32).intersects(12) or sprite(32).intersects(11) or sprite(32).intersects(10) or sprite(32).intersects(3) then
  57.         pLocH = pLocH - h
  58.         pLocV = pLocV - v
  59.       else
  60.         sheepSounds()
  61.         SheepCounter()
  62.       end if
  63.     else
  64.       if gLevel = 3 then
  65.         if sprite(32).intersects(8) or sprite(32).intersects(5) or sprite(32).intersects(13) or sprite(32).intersects(12) or sprite(32).intersects(11) or sprite(32).intersects(10) or sprite(32).intersects(3) then
  66.           pLocH = pLocH - h
  67.           pLocV = pLocV - v
  68.         else
  69.           sheepSounds()
  70.           SheepCounter()
  71.         end if
  72.       else
  73.         if gLevel = 4 then
  74.           if sprite(32).intersects(8) or sprite(32).intersects(5) or sprite(32).intersects(13) or sprite(32).intersects(12) or sprite(32).intersects(11) or sprite(32).intersects(10) or sprite(32).intersects(3) then
  75.             pLocH = pLocH - h
  76.             pLocV = pLocV - v
  77.           else
  78.             sheepSounds()
  79.             SheepCounter()
  80.           end if
  81.         else
  82.           if gLevel = 5 then
  83.             if sprite(32).intersects(8) or sprite(32).intersects(16) or sprite(32).intersects(5) or sprite(32).intersects(13) or sprite(32).intersects(12) or sprite(32).intersects(11) or sprite(32).intersects(10) or sprite(32).intersects(3) then
  84.               pLocH = pLocH - h
  85.               pLocV = pLocV - v
  86.             else
  87.               sheepSounds()
  88.               SheepCounter()
  89.             end if
  90.           else
  91.             if gLevel = 6 then
  92.               if sprite(32).intersects(5) or sprite(32).intersects(12) or sprite(32).intersects(11) or sprite(32).intersects(10) or sprite(32).intersects(3) then
  93.                 pLocH = pLocH - h
  94.                 pLocV = pLocV - v
  95.               else
  96.                 sheepSounds()
  97.                 SheepCounter()
  98.               end if
  99.             else
  100.               if gLevel = 7 then
  101.                 if sprite(32).intersects(5) or sprite(32).intersects(12) or sprite(32).intersects(11) or sprite(32).intersects(10) or sprite(32).intersects(3) or sprite(32).intersects(13) or sprite(32).intersects(14) then
  102.                   pLocH = pLocH - h
  103.                   pLocV = pLocV - v
  104.                 else
  105.                   sheepSounds()
  106.                   SheepCounter()
  107.                 end if
  108.               end if
  109.             end if
  110.           end if
  111.         end if
  112.       end if
  113.     end if
  114.   end if
  115. end
  116.  
  117. on sheepSounds
  118.   if the timer > pWait4Step then
  119.     if spriteNum = 37 then
  120.       puppetSound(1, "hof4b")
  121.     else
  122.       if spriteNum = 38 then
  123.         puppetSound(2, "hof4c")
  124.       else
  125.         if spriteNum = 39 then
  126.           puppetSound(3, "hof4b")
  127.         end if
  128.       end if
  129.     end if
  130.     pWait4Step = the timer + 55 - (pSheepSpeed * 10)
  131.     if pWait4Step < (the timer + 12) then
  132.       pWait4Step = the timer + 12
  133.     end if
  134.   end if
  135. end
  136.