home *** CD-ROM | disk | FTP | other *** search
/ Guia CD-ROM 25 / GUIACD25.iso / bht / 02.dir / 00677.ls < prev    next >
Encoding:
Text File  |  1996-02-08  |  4.8 KB  |  175 lines

  1. on initNavMovies
  2.   global NavPlayer1, Player2
  3.   if objectp(NavPlayer1) then
  4.     NavPlayer1(mdispose)
  5.   end if
  6.   set NavPlayer1 to navMoviePlayer(mnew)
  7. end
  8.  
  9. on openNavMovie theNavMoviePlayer, movieChannel
  10.   theNavMoviePlayer(mLoadMovie, movieChannel)
  11. end
  12.  
  13. factory navMoviePlayer
  14. method mnew
  15.   instance startMovie, startMovie, startMovie, startMovie, startMovie, startMovie, startMovie, startMovie, startMovie, startMovie, startMovie, startMovie, startMovie, nmSprite, nmCast, nmRows, nmColumns, nmDirectionality, nmLoopSize, nmTScale, nmHCenter, nmVCenter, nmDeadZone, nmMaxZone, nmDelayScale, nmCurrRow, nmCurrColumn
  16.  
  17. method mLoadMovie aNavMovieSprite
  18.   set nmSprite to aNavMovieSprite
  19.   set nmCast to the castNum of sprite nmSprite
  20.   me(mSetUp)
  21.  
  22. method mSetUp
  23.   me(mReadParms)
  24.   me(mSetPlayerParms)
  25.   me(mGotoRowColumn, integer((nmRows / 2) + 0.5), integer((nmColumns / 2) + 0.5))
  26.   set the movieRate of sprite nmSprite to 0
  27.  
  28. method mReadParms
  29.   set nmRows to 0
  30.   set nmColumns to 0
  31.   set nmDirectionality to 0
  32.   set nmLoopSize to 1
  33.   set parmList to the name of cast the castNum of sprite nmSprite
  34.   delete item 1 of parmList
  35.   repeat with i = 1 to the number of items in parmList
  36.     set aParm to item i of parmList
  37.     set parmTag to char 1 of aParm
  38.     delete char 1 of aParm
  39.     if parmTag = "r" then
  40.       set nmRows to aParm
  41.       next repeat
  42.     end if
  43.     if parmTag = "c" then
  44.       set nmColumns to aParm
  45.       next repeat
  46.     end if
  47.     if parmTag = "d" then
  48.       set nmDirectionality to aParm
  49.       next repeat
  50.     end if
  51.     if parmTag = "l" then
  52.       set nmLoopSize to aParm
  53.     end if
  54.   end repeat
  55.  
  56. method mSetPlayerParms
  57.   set nmHCenter to the locH of sprite nmSprite
  58.   set nmVCenter to the locV of sprite nmSprite
  59.   set nmTScale to integer(the duration of cast nmCast / (nmRows * nmColumns))
  60.   set nmDeadZone to 30
  61.   set nmMaxZone to integer(the height of sprite nmSprite / 2)
  62.   set nmDelayScale to integer(nmMaxZone * nmMaxZone / 30)
  63.  
  64. method mGotoRowColumn theRow, theColumn
  65.   set nmCurrRow to theRow
  66.   set nmCurrColumn to theColumn
  67.   set currFrame to integer(((nmCurrRow - 1) * nmColumns) + nmCurrColumn)
  68.   set the movieTime of sprite nmSprite to integer(currFrame - 1) * nmTScale
  69.   updateStage()
  70.  
  71. method mJoystickController
  72.   repeat while the mouseDown
  73.     if rollOver(nmSprite) then
  74.       set nextRow to nmCurrRow
  75.       set nextColumn to nmCurrColumn
  76.       set joyDH to the mouseH - nmHCenter
  77.       set joyDV to the mouseV - nmVCenter
  78.       set cursorNum to me(mJoyCursor, joyDH, joyDV)
  79.       set cursorName to me(mJoyCursorName, cursorNum)
  80.       if cursorName contains "S" then
  81.         if nextRow < nmRows then
  82.           set nextRow to nextRow + 1
  83.         else
  84.           set nextRow to nextRow + 0
  85.         end if
  86.       else
  87.         if cursorName contains "N" then
  88.           if nextRow > 1 then
  89.             set nextRow to nextRow - 1
  90.           else
  91.             set nextRow to nextRow + 0
  92.           end if
  93.         end if
  94.       end if
  95.       if cursorName contains "E" then
  96.         if nextColumn < nmColumns then
  97.           set nextColumn to nextColumn + 1
  98.         else
  99.           set nextColumn to 1
  100.         end if
  101.       else
  102.         if cursorName contains "W" then
  103.           if nextColumn > 1 then
  104.             set nextColumn to nextColumn - 1
  105.           else
  106.             set nextColumn to nmColumns
  107.           end if
  108.         end if
  109.       end if
  110.       cursor(cursorNum + 1100)
  111.       if cursorName <> EMPTY then
  112.         me(mGotoRowColumn, nextRow, nextColumn)
  113.         set navDelay to integer(((nmMaxZone * nmMaxZone) - (joyDH * joyDH) - (joyDV * joyDV)) / nmDelayScale)
  114.         if navDelay > 0 then
  115.           startTimer()
  116.           repeat while the timer < navDelay
  117.           end repeat
  118.         end if
  119.       end if
  120.       next repeat
  121.     end if
  122.     when mouseDown then nothing
  123.     cursor(0)
  124.   end repeat
  125.   cursor(0)
  126.  
  127. method mJoyCursor joyDH, joyDV
  128.   if joyDV > nmDeadZone then
  129.     if joyDH < -nmDeadZone then
  130.       set cursorNum to 6
  131.     else
  132.       if joyDH > nmDeadZone then
  133.         set cursorNum to 7
  134.       else
  135.         set cursorNum to 2
  136.       end if
  137.     end if
  138.   else
  139.     if joyDV < -nmDeadZone then
  140.       if joyDH < -nmDeadZone then
  141.         set cursorNum to 5
  142.       else
  143.         if joyDH > nmDeadZone then
  144.           set cursorNum to 4
  145.         else
  146.           set cursorNum to 3
  147.         end if
  148.       end if
  149.     else
  150.       if joyDH < -nmDeadZone then
  151.         set cursorNum to 1
  152.       else
  153.         if joyDH > nmDeadZone then
  154.           set cursorNum to 0
  155.         else
  156.           set cursorNum to 8
  157.         end if
  158.       end if
  159.     end if
  160.   end if
  161.   return cursorNum
  162.  
  163. method mJoyCursorName cursorNum
  164.   return item cursorNum + 1 of "E,W,S,N,NE,NW,SW,SE,"
  165.  
  166. method mShowNavCursor theCursorH, theCursorV
  167.   if the mouseCast = -1 then
  168.     cursor(-1)
  169.   else
  170.     if rollOver(nmSprite) then
  171.       set theCursorNum to me(mJoyCursor, theCursorH - nmHCenter, theCursorV - nmVCenter)
  172.       cursor(1110 + theCursorNum)
  173.     end if
  174.   end if
  175.