home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / PegScramble.dxr / 00003.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  4.6 KB  |  141 lines

  1. global holeData, pegData, spinFactor, grabbedPiece, gottaRedraw
  2.  
  3. on drawChart chartPercentage
  4.   chartPercentage = integer(chartPercentage)
  5.   if chartPercentage < 0 then
  6.     chartPercentage = 0
  7.   end if
  8.   if chartPercentage > 100 then
  9.     chartPercentage = 100
  10.   end if
  11.   if chartPercentage <= 0 then
  12.     cVector = 0
  13.   else
  14.     if (chartPercentage > 0) and (chartPercentage <= 25) then
  15.       cVector = 1
  16.     else
  17.       if (chartPercentage > 25) and (chartPercentage <= 50) then
  18.         cVector = 2
  19.       else
  20.         if (chartPercentage > 50) and (chartPercentage <= 75) then
  21.           cVector = 3
  22.         else
  23.           if (chartPercentage > 75) and (chartPercentage <= 100) then
  24.             cVector = 4
  25.           else
  26.             cVector = 5
  27.           end if
  28.         end if
  29.       end if
  30.     end if
  31.   end if
  32.   repeat with wvect = 1 to 4
  33.     if cVector > (wvect - 1) then
  34.       sprite(10 + wvect).visible = 1
  35.       sprite(10 + wvect).skew = 0
  36.       next repeat
  37.     end if
  38.     sprite(10 + wvect).visible = 0
  39.     sprite(10 + wvect).skew = 0
  40.   end repeat
  41.   if (chartPercentage mod 25) = 0 then
  42.     sprite(10 + cVector).skew = 0
  43.   else
  44.     sprite(10 + cVector).skew = ((chartPercentage mod 25) - 25) * 90 / 25
  45.   end if
  46. end
  47.  
  48. on drawSlots reDraw
  49.   global totalCompleted, unfinishedSlots, maximumPegs
  50.   totalCompleted = 0
  51.   unfinishedSlots = 0
  52.   repeat with wSlot = 1 to count(holeData)
  53.     slotAim = holeData[wSlot][1]
  54.     slotDist = holeData[wSlot][2]
  55.     slotCircle = holeData[wSlot][3]
  56.     slotSpin = holeData[wSlot][4]
  57.     slotShape = holeData[wSlot][5]
  58.     slotStatus = holeData[wSlot][6]
  59.     slotSpin = 0
  60.     if slotStatus <> 0 then
  61.       totalCompleted = totalCompleted + 1
  62.     else
  63.       unfinishedSlots = unfinishedSlots + 1
  64.     end if
  65.     spinAdjust = spinFactor[slotCircle]
  66.     locY = integer(cos((slotAim + spinAdjust) * PI / 180) * -slotDist)
  67.     locX = integer(sin((slotAim + spinAdjust) * PI / 180) * slotDist)
  68.     wSprite = 30 + wSlot
  69.     set the loc of sprite wSprite to the loc of sprite 5 + point(locX, locY)
  70.     if reDraw = 1 then
  71.       if slotStatus <> 0 then
  72.         set the member of sprite wSprite to "Shape " & string(slotShape)
  73.       else
  74.         set the member of sprite wSprite to "Slot " & string(slotShape)
  75.       end if
  76.     end if
  77.     sprite(wSprite).rotation = 0
  78.     if (grabbedPiece <> 0) and (slotStatus = 0) then
  79.       if pegData[grabbedPiece][4] = 0 then
  80.         testLoc = pegData[grabbedPiece][1]
  81.         testAim = pegData[grabbedPiece][2]
  82.         testType = pegData[grabbedPiece][3]
  83.         testAim = 0
  84.         if findDistance(testLoc, the loc of sprite 5 + point(locX, locY)) <= 5 then
  85.           locY1 = integer(cos(testAim * PI / 180) * -100)
  86.           locX1 = integer(sin(testAim * PI / 180) * 100)
  87.           locY2 = integer(cos((slotSpin + spinAdjust) * PI / 180) * -100)
  88.           locX2 = integer(sin((slotSpin + spinAdjust) * PI / 180) * 100)
  89.           if findDistance(point(locX1, locY1), point(locX2, locY2)) <= 25 then
  90.             if slotShape = testType then
  91.               pegData[grabbedPiece][4] = wSlot
  92.               pegData[grabbedPiece][1] = point(-50, -50)
  93.               holeData[wSlot][6] = grabbedPiece
  94.               set the loc of sprite (100 + grabbedPiece) to point(-50, -50)
  95.               grabbedPiece = 0
  96.               gottaRedraw = 1
  97.             end if
  98.           end if
  99.         end if
  100.       end if
  101.     end if
  102.   end repeat
  103.   if gottaRedraw = 1 then
  104.     drawChart(totalCompleted * 100 / maximumPegs)
  105.     playSound("drop_in_correct_placeholder", 3)
  106.   end if
  107. end
  108.  
  109. on drawpegs
  110.   repeat with wPeg = 1 to count(pegData)
  111.     if pegData[wPeg][4] = 0 then
  112.       set the loc of sprite (100 + wPeg) to pegData[wPeg][1]
  113.       set the member of sprite (100 + wPeg) to "Shape " & string(pegData[wPeg][3])
  114.       sprite(100 + wPeg).rotation = 0
  115.       sprite(100 + wPeg).locZ = 150
  116.       next repeat
  117.     end if
  118.     parentSprite = 30 + pegData[wPeg][4]
  119.     set the loc of sprite (100 + wPeg) to the loc of sprite parentSprite
  120.     set the member of sprite (100 + wPeg) to "Shape " & string(pegData[wPeg][3])
  121.     sprite(100 + wPeg).rotation = 0
  122.     sprite(100 + wPeg).locZ = 100
  123.   end repeat
  124. end
  125.  
  126. on updatePeg
  127.   if grabbedPiece <> 0 then
  128.     wPeg = grabbedPiece
  129.     if pegData[wPeg][4] = 0 then
  130.       set the loc of sprite (100 + wPeg) to pegData[wPeg][1]
  131.       set the member of sprite (100 + wPeg) to "Shape " & string(pegData[wPeg][3])
  132.       sprite(100 + wPeg).rotation = 0
  133.     else
  134.       parentSprite = 30 + pegData[wPeg][4]
  135.       set the loc of sprite (100 + wPeg) to the loc of sprite parentSprite
  136.       set the member of sprite (100 + wPeg) to "Shape " & string(pegData[wPeg][3])
  137.       sprite(100 + wPeg).rotation = sprite(parentSprite).rotation
  138.     end if
  139.   end if
  140. end
  141.