home *** CD-ROM | disk | FTP | other *** search
/ GQ - Louise, World Cup, …remy Clarkson, Armageddon / GQCD.iso / files / modlmain.dxr / 00058_scrollerScript.ls < prev    next >
Encoding:
Text File  |  1998-05-21  |  2.8 KB  |  91 lines

  1. property bannerSprite, selectorSprite, myScrollDelay, minSafeArea, maxSafeArea, minOffset, maxOffset
  2. global gSelectedPicture, gMasterObj
  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.   puppetSprite(bannerSprite, 1)
  20.   puppetSprite(selectorSprite, 1)
  21. end
  22.  
  23. on stepFrame me
  24.   set topArea to the top of sprite bannerSprite
  25.   set bottomArea to the bottom of sprite bannerSprite
  26.   if (the mouseV > topArea) and (the mouseV < bottomArea) then
  27.     if the mouseH > maxSafeArea then
  28.       setCursorExemption(gMasterObj, 1)
  29.       set myDirection to (the mouseH - (maxSafeArea - 10)) / myScrollDelay
  30.       scrollLeft(me, myDirection)
  31.       cursor([5, 6])
  32.     else
  33.       if the mouseH < minSafeArea then
  34.         setCursorExemption(gMasterObj, 1)
  35.         set myDirection to (the mouseH - (minSafeArea + 10)) / myScrollDelay
  36.         scrollRight(me, myDirection)
  37.         cursor([3, 4])
  38.       else
  39.         setCursorExemption(gMasterObj, 1)
  40.         cursor([1, 2])
  41.       end if
  42.     end if
  43.     updateSelector(me)
  44.   else
  45.     removeSelector(me)
  46.   end if
  47. end
  48.  
  49. on updateSelector me
  50.   repeat with i = -25 to 35
  51.     set minValue to (39 * (i - 2)) + (the locH of sprite bannerSprite - 320) + 20
  52.     set maxValue to (39 * (i - 1)) + (the locH of sprite bannerSprite - 320) + 21
  53.     set myValue to (39 * (i - 1)) + (the locH of sprite bannerSprite - 320) + 1
  54.     if (the mouseH > minValue) and (the mouseH < maxValue) then
  55.       set the locH of sprite selectorSprite to myValue
  56.       set gSelectedPicture to i + 11
  57.       if gSelectedPicture > 23 then
  58.         set gSelectedPicture to gSelectedPicture - 23
  59.       end if
  60.       put gSelectedPicture
  61.       exit repeat
  62.     end if
  63.   end repeat
  64. end
  65.  
  66. on removeSelector me
  67.   if the locH of sprite selectorSprite <> -100 then
  68.     set the locH of sprite selectorSprite to -100
  69.   end if
  70. end
  71.  
  72. on scrollLeft me, myDirection
  73.   set newPos to the locH of sprite bannerSprite - myDirection
  74.   if newPos < minOffset then
  75.     set myRemainder to minOffset - newPos
  76.     set the locH of sprite bannerSprite to maxOffset - myRemainder
  77.   else
  78.     set the locH of sprite bannerSprite to newPos
  79.   end if
  80. end
  81.  
  82. on scrollRight me, myDirection
  83.   set newPos to the locH of sprite bannerSprite - myDirection
  84.   if newPos > maxOffset then
  85.     set myRemainder to newPos - maxOffset
  86.     set the locH of sprite bannerSprite to minOffset + myRemainder
  87.   else
  88.     set the locH of sprite bannerSprite to newPos
  89.   end if
  90. end
  91.