home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 December / macformat-044.iso / Demos / The Ghost Cave / BB / RBB / PUZ.Dxr / 00009_piece parent.ls < prev    next >
Encoding:
Text File  |  1996-06-14  |  6.3 KB  |  238 lines

  1. property mysound, myseq, mysprite, mycast, mystH, mystV, myenH, myenV, isHeard, active, myname
  2.  
  3. on birth me, pos, rand, chnum
  4.   global offs, offs2
  5.   set mysound to word pos of field "sounds"
  6.   set myname to word chnum of field "names"
  7.   set mysprite to pos + offs
  8.   set mycast to the number of cast myname + pos
  9.   set mystH to value(word rand of field (myname & "stHs"))
  10.   set mystV to value(word rand of field (myname & "stVs"))
  11.   set myenH to value(word pos of field (myname & "enHs"))
  12.   set myenV to value(word pos of field (myname & "enVs"))
  13.   set active to 1
  14.   set the castNum of sprite mysprite to mycast
  15.   set the locH of sprite mysprite to mystH
  16.   set the locV of sprite mysprite to mystV
  17.   return me
  18. end
  19.  
  20. on say me
  21.   puppetSound(mysound)
  22.   updateStage()
  23. end
  24.  
  25. on highlight me
  26.   global emtol, blankcast, whichsprite, whichword, mover, moverspr
  27.   if active then
  28.     set the castNum of sprite moverspr to mycast
  29.     set the castNum of sprite mysprite to blankcast
  30.     set mover to mysprite
  31.     set the visible of sprite moverspr to 1
  32.   end if
  33. end
  34.  
  35. on unhighlight1 me
  36.   global moverspr
  37.   if active then
  38.     set the castNum of sprite moverspr to mycast
  39.     puppetSound(0)
  40.     updateStage()
  41.   end if
  42. end
  43.  
  44. on unhighlight2 me
  45.   global blankcast, mover, moverspr
  46.   set the castNum of sprite moverspr to blankcast
  47.   set mover to 2
  48.   set the castNum of sprite mysprite to mycast
  49. end
  50.  
  51. on iscorrect me, curx, cury
  52.   global numCorrect, blankcast, whichsprite, emtol
  53.   if (abs(curx - myenH) <= emtol) and (abs(cury - myenV) <= emtol) then
  54.     return 1
  55.   else
  56.     return(FLASE)
  57.   end if
  58. end
  59.  
  60. on finish me
  61.   global numCorrect
  62.   if active then
  63.     set numCorrect to numCorrect + 1
  64.     set the locH of sprite mysprite to myenH
  65.     set the locV of sprite mysprite to myenV
  66.     puppetSound("positive")
  67.     set active to 0
  68.     set the moveableSprite of sprite mysprite to 0
  69.   end if
  70. end
  71.  
  72. on moveBackDown me, curH, curV
  73.   global moverspr
  74.   set stpsz to 8
  75.   set curH to the locH of sprite moverspr
  76.   set curV to the locV of sprite moverspr
  77.   set dV to float(mystV - curV)
  78.   set dH to float(mystH - curH)
  79.   if dH <> 0 then
  80.     if dH < 0 then
  81.       set sgn to -1
  82.     else
  83.       set sgn to 1
  84.     end if
  85.     set theta to atan(dV / dH)
  86.     set dist to sqrt((dV * dV) + (dH * dH))
  87.     repeat while not checkIn(curH, curV, mystH, mystV, stpsz)
  88.       set curH to curH + (sgn * stpsz * cos(theta))
  89.       set curV to curV + (sgn * stpsz * sin(theta))
  90.       set the locH of sprite moverspr to curH
  91.       set the locV of sprite moverspr to curV
  92.       updateStage()
  93.     end repeat
  94.     set the locH of sprite moverspr to mystH
  95.     set the locV of sprite moverspr to mystV
  96.     set the locH of sprite mysprite to mystH
  97.     set the locV of sprite mysprite to mystV
  98.     updateStage()
  99.   else
  100.     if dV < 0 then
  101.       set sgn to -1
  102.     else
  103.       set sgn to 1
  104.     end if
  105.     repeat while not checkIn(curH, curV, mystH, mystV, stpsz)
  106.       set curV to curV + (sgn * stpsz)
  107.       set the locV of sprite moverspr to curV
  108.       updateStage()
  109.     end repeat
  110.     set the locH of sprite moverspr to mystH
  111.     set the locV of sprite moverspr to mystV
  112.     set the locH of sprite mysprite to mystH
  113.     set the locV of sprite mysprite to mystV
  114.   end if
  115. end
  116.  
  117. on checkIn x, y, endx, endy, tol
  118.   if (abs(x - endx) <= tol) and (abs(y - endy) <= tol) then
  119.     return 1
  120.   else
  121.     return 0
  122.   end if
  123. end
  124.  
  125. on canHelp me
  126.   if active then
  127.     return 1
  128.   else
  129.     return 0
  130.   end if
  131. end
  132.  
  133. on dohelp me
  134.   global numCorrect
  135.   set nofrs to 25
  136.   stopEvents()
  137.   puppetSound("TsayHelp.AIF")
  138.   updateStage()
  139.   repeat while soundBusy(1)
  140.   end repeat
  141.   set the puppet of sprite 48 to 1
  142.   set the castNum of sprite 48 to the number of cast "cursorcast"
  143.   set the visible of sprite 48 to 1
  144.   set the locH of sprite 48 to the mouseH
  145.   set the locV of sprite 48 to the mouseV
  146.   set the castNum of sprite 47 to the number of cast "mouse U"
  147.   set the locH of sprite 47 to -75
  148.   set the locV of sprite 47 to 300
  149.   set the visible of sprite 47 to 1
  150.   cursor(200)
  151.   rollOutMouse()
  152.   puppetSound("drag")
  153.   set startH to the mouseH
  154.   set startV to the mouseV
  155.   set finH to the locH of sprite mysprite
  156.   set finV to the locV of sprite mysprite
  157.   set stpH to float(finH - startH) / float(nofrs)
  158.   set stpV to float(finV - startV) / float(nofrs)
  159.   repeat with j = 1 to nofrs
  160.     set the locH of sprite 48 to startH + integer(j * stpH)
  161.     set the locV of sprite 48 to startV + integer(j * stpV)
  162.     updateStage()
  163.   end repeat
  164.   set the locH of sprite 48 to finH
  165.   set the locV of sprite 48 to finV
  166.   updateStage()
  167.   puppetSound(0)
  168.   wait(60)
  169.   set the castNum of sprite 47 to the number of cast "mouse D"
  170.   puppetSound("switch")
  171.   updateStage()
  172.   wait(60)
  173.   puppetSound("drag")
  174.   set startH to the locH of sprite mysprite
  175.   set startV to the locV of sprite mysprite
  176.   set finH to myenH
  177.   set finV to myenV
  178.   set stpH to float(finH - startH) / float(nofrs)
  179.   set stpV to float(finV - startV) / float(nofrs)
  180.   repeat with j = 1 to nofrs
  181.     set the locH of sprite 48 to startH + integer(j * stpH)
  182.     set the locV of sprite 48 to startV + integer(j * stpV)
  183.     set the locH of sprite mysprite to startH + integer(j * stpH)
  184.     set the locV of sprite mysprite to startV + integer(j * stpV)
  185.     updateStage()
  186.   end repeat
  187.   set the locH of sprite mysprite to myenH
  188.   set the locV of sprite mysprite to myenV
  189.   set the castNum of sprite 47 to the number of cast "mouse U"
  190.   puppetSound("positive")
  191.   updateStage()
  192.   wait(60)
  193.   rollBackMouse()
  194.   set the visible of sprite 48 to 0
  195.   set the puppet of sprite 48 to 0
  196.   set the visible of sprite 47 to 0
  197.   puppetSound(0)
  198.   cursor([90, 91])
  199.   set active to 0
  200.   set numCorrect to numCorrect + 1
  201.   set the moveableSprite of sprite mysprite to 0
  202.   startEvents()
  203. end
  204.  
  205. on rollBackMouse
  206.   set widthOfMouse to 143
  207.   puppetSound("FORKSTRT.AIF")
  208.   set stH to the locH of sprite 47
  209.   set i to stH
  210.   repeat while i > (stH - widthOfMouse)
  211.     set i to i - 3
  212.     set the locH of sprite 47 to i
  213.     updateStage()
  214.   end repeat
  215.   puppetSound("FORKSTOP.AIF")
  216.   updateStage()
  217.   repeat while soundBusy(1)
  218.   end repeat
  219.   puppetSound(0)
  220. end
  221.  
  222. on rollOutMouse
  223.   set widthOfMouse to 143
  224.   puppetSound("FORKSTRT.AIF")
  225.   set stH to the locH of sprite 47
  226.   set i to stH
  227.   repeat while i < (stH + widthOfMouse)
  228.     set i to i + 3
  229.     set the locH of sprite 47 to i
  230.     updateStage()
  231.   end repeat
  232.   puppetSound("FORKSTOP.AIF")
  233.   updateStage()
  234.   repeat while soundBusy(1)
  235.   end repeat
  236.   puppetSound(0)
  237. end
  238.