home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / optimus / agata / home.dir / 00013_crystal.ls < prev    next >
Encoding:
Text File  |  1997-02-20  |  1.5 KB  |  57 lines

  1. property myChan, maxFrames, currFrame, castList, animating, firstAnimation
  2.  
  3. on birth me, chan
  4.   set firstAnimation to 1
  5.   set the castList of me to [576, 575, 574, 573, 572, 571]
  6.   set myChan to chan
  7.   set the stretch of sprite myChan to 0
  8.   set animating to 0
  9.   set the maxFrames of me to count(castList)
  10.   return me
  11. end
  12.  
  13. on startAnimation me
  14.   global theCoord
  15.   set loc to getProp(the layout of theCoord, #crystalroom)
  16.   set x to getAt(loc, 1)
  17.   set y to getAt(loc, 2)
  18.   set the locH of sprite the myChan of me to x
  19.   set the locV of sprite the myChan of me to y
  20.   set currFrame to 1
  21. end
  22.  
  23. on Animate me
  24.   global theCoord
  25.   if animating then
  26.     if currFrame <= maxFrames then
  27.       set castIndex to getAt(castList, currFrame)
  28.       set the castNum of sprite myChan to castIndex
  29.     else
  30.       set the castNum of sprite myChan to 571
  31.       set animating to 0
  32.     end if
  33.     set currFrame to currFrame + 1
  34.   else
  35.     set the castNum of sprite myChan to 571
  36.     if firstAnimation then
  37.       set rand to 1
  38.       set firstAnimation to 0
  39.     else
  40.       set rand to random(30)
  41.     end if
  42.     if rand = 1 then
  43.       set animating to 1
  44.       startAnimation(me)
  45.     end if
  46.   end if
  47.   if not (the cursorHidden of theCoord) then
  48.     if ((the mouseCast > 570) and (the mouseCast <= 577)) or (the mouseCast = 38) or the inHelp of theCoord then
  49.       set the castNum of sprite myChan to 577
  50.     end if
  51.   else
  52.     if the inHelp of theCoord then
  53.       set the castNum of sprite myChan to 577
  54.     end if
  55.   end if
  56. end
  57.