home *** CD-ROM | disk | FTP | other *** search
/ Shocking The Web CD-ROM / SHOCK_CD.ISO / pc / tutorial / ch06_med / smiley / smiley.dir / 00053.ls < prev    next >
Encoding:
Text File  |  1996-12-02  |  1.9 KB  |  94 lines

  1. on startMovie
  2.   global glistCount, gcolorList
  3.   set gcolorList to list(156, 76, 19, 96)
  4. end
  5.  
  6. on puppetsOn
  7.   puppetSprite(4, 1)
  8.   puppetSprite(14, 1)
  9.   puppetSprite(15, 1)
  10.   puppetSprite(40, 1)
  11.   puppetSprite(41, 1)
  12.   puppetSprite(42, 1)
  13.   puppetSprite(43, 1)
  14.   puppetSprite(44, 1)
  15. end
  16.  
  17. on puppetsOff
  18.   puppetSprite(14, 0)
  19.   puppetSprite(15, 0)
  20. end
  21.  
  22. on waitfor seconds
  23.   global getit
  24.   set now to the timer
  25.   repeat while the timer < (now + (seconds * 60))
  26.     if the mouseDown then
  27.       exit
  28.     end if
  29.   end repeat
  30. end
  31.  
  32. on runaway
  33.   waitfor(0.20000000000000001)
  34.   puppetSound("giggle")
  35.   set newH to random(the stageRight - the stageLeft)
  36.   set newV to random(the stageBottom - the stageTop)
  37.   moveSprtDiag(4, newH, newV)
  38. end
  39.  
  40. on closeWindow
  41.   tell the stage
  42.     cleanUpMIAW()
  43.   end tell
  44. end
  45.  
  46. on moveSprtDiag whchSprt, newH, newV
  47.   set x1 to the locH of sprite whchSprt
  48.   set y1 to the locV of sprite whchSprt
  49.   set x2 to newH
  50.   set y2 to newV
  51.   set stepSize to 10
  52.   set stepDelay to 0
  53.   if x1 > x2 then
  54.     set xVal to -1
  55.   else
  56.     set xVal to 1
  57.   end if
  58.   if y1 > y2 then
  59.     set yVal to -1
  60.   else
  61.     set yVal to 1
  62.   end if
  63.   set xDist to abs(x2 - x1)
  64.   set yDist to abs(y2 - y1)
  65.   set x to x1 * 1.0
  66.   set y to y1 * 1.0
  67.   if yDist > xDist then
  68.     set steps to yDist
  69.     set xFact to 1.0 * xDist / yDist * stepSize
  70.     set yFact to stepSize
  71.   else
  72.     set steps to xDist
  73.     set xFact to stepSize
  74.     set yFact to 1.0 * yDist / xDist * stepSize
  75.   end if
  76.   repeat while (x <> x2) or (y <> y2)
  77.     set x to x + (xFact * xVal)
  78.     set y to y + (yFact * yVal)
  79.     if abs(x - x2) <= xFact then
  80.       set x to x2
  81.     end if
  82.     if abs(y - y2) <= yFact then
  83.       set y to y2
  84.     end if
  85.     set the locH of sprite whchSprt to integer(x)
  86.     set the locV of sprite whchSprt to integer(y)
  87.     updateStage()
  88.     set curTicks to the ticks
  89.     repeat while the ticks < (curTicks + stepDelay)
  90.       nothing()
  91.     end repeat
  92.   end repeat
  93. end
  94.