home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 July / DPPCPRO0799.ISO / Ents / Files / model.dxr / 00055_scrollerScript.ls < prev    next >
Encoding:
Text File  |  1999-04-21  |  2.7 KB  |  85 lines

  1. property bannerSprite, selectorSprite, myScrollDelay, minSafeArea, maxSafeArea, minOffset, maxOffset
  2. global gSelectedPicture
  3.  
  4. on new me
  5.   append(the actorList, me)
  6.   return me
  7. end
  8.  
  9. on init me, whichBannerSprite, whichSelectorSprite, scrollDelay, safeArea
  10.   set bannerSprite to whichBannerSprite
  11.   set selectorSprite to whichSelectorSprite
  12.   set myScrollDelay to scrollDelay
  13.   set myOffset to safeArea / 2.0
  14.   set minSafeArea to 321 - myOffset
  15.   set maxSafeArea to 320 + myOffset
  16.   set myOffset to (the width of sprite bannerSprite - 1280) / 2.0
  17.   set minOffset to 0 - myOffset
  18.   set maxOffset to 640 + myOffset
  19. end
  20.  
  21. on stepFrame me
  22.   set topArea to the top of sprite bannerSprite
  23.   set bottomArea to the bottom of sprite bannerSprite
  24.   if (the mouseV > topArea) and (the mouseV < bottomArea) then
  25.     if the mouseH > maxSafeArea then
  26.       set myDirection to (the mouseH - (maxSafeArea - 10)) / myScrollDelay
  27.       scrollLeft(me, myDirection)
  28.       set the cursor of sprite bannerSprite to [11, 12]
  29.     else
  30.       if the mouseH < minSafeArea then
  31.         set myDirection to (the mouseH - (minSafeArea + 10)) / myScrollDelay
  32.         scrollRight(me, myDirection)
  33.         set the cursor of sprite bannerSprite to [9, 10]
  34.       else
  35.         set the cursor of sprite bannerSprite to [1, 2]
  36.       end if
  37.     end if
  38.     updateSelector(me)
  39.   else
  40.     removeSelector(me)
  41.   end if
  42. end
  43.  
  44. on updateSelector me
  45.   repeat with i = -25 to 35
  46.     set minValue to (39 * (i - 2)) + (the locH of sprite bannerSprite - 320) + 20
  47.     set maxValue to (39 * (i - 1)) + (the locH of sprite bannerSprite - 320) + 21
  48.     set myValue to (39 * (i - 1)) + (the locH of sprite bannerSprite - 320) + 1
  49.     if (the mouseH > minValue) and (the mouseH < maxValue) then
  50.       set the locH of sprite selectorSprite to myValue
  51.       set gSelectedPicture to i + 11
  52.       if gSelectedPicture > 23 then
  53.         set gSelectedPicture to gSelectedPicture - 23
  54.       end if
  55.       exit repeat
  56.     end if
  57.   end repeat
  58. end
  59.  
  60. on removeSelector me
  61.   if the locH of sprite selectorSprite <> -100 then
  62.     set the locH of sprite selectorSprite to -100
  63.   end if
  64. end
  65.  
  66. on scrollLeft me, myDirection
  67.   set newPos to the locH of sprite bannerSprite - myDirection
  68.   if newPos < minOffset then
  69.     set myRemainder to minOffset - newPos
  70.     set the locH of sprite bannerSprite to maxOffset - myRemainder
  71.   else
  72.     set the locH of sprite bannerSprite to newPos
  73.   end if
  74. end
  75.  
  76. on scrollRight me, myDirection
  77.   set newPos to the locH of sprite bannerSprite - myDirection
  78.   if newPos > maxOffset then
  79.     set myRemainder to newPos - maxOffset
  80.     set the locH of sprite bannerSprite to minOffset + myRemainder
  81.   else
  82.     set the locH of sprite bannerSprite to newPos
  83.   end if
  84. end
  85.