home *** CD-ROM | disk | FTP | other *** search
- global holeData, pegData, spinFactor, grabbedPiece, gottaRedraw
-
- on drawChart chartPercentage
- chartPercentage = integer(chartPercentage)
- if chartPercentage < 0 then
- chartPercentage = 0
- end if
- if chartPercentage > 100 then
- chartPercentage = 100
- end if
- if chartPercentage <= 0 then
- cVector = 0
- else
- if (chartPercentage > 0) and (chartPercentage <= 25) then
- cVector = 1
- else
- if (chartPercentage > 25) and (chartPercentage <= 50) then
- cVector = 2
- else
- if (chartPercentage > 50) and (chartPercentage <= 75) then
- cVector = 3
- else
- if (chartPercentage > 75) and (chartPercentage <= 100) then
- cVector = 4
- else
- cVector = 5
- end if
- end if
- end if
- end if
- end if
- repeat with wvect = 1 to 4
- if cVector > (wvect - 1) then
- sprite(10 + wvect).visible = 1
- sprite(10 + wvect).skew = 0
- next repeat
- end if
- sprite(10 + wvect).visible = 0
- sprite(10 + wvect).skew = 0
- end repeat
- if (chartPercentage mod 25) = 0 then
- sprite(10 + cVector).skew = 0
- else
- sprite(10 + cVector).skew = ((chartPercentage mod 25) - 25) * 90 / 25
- end if
- end
-
- on drawSlots reDraw
- global totalCompleted, unfinishedSlots, maximumPegs
- totalCompleted = 0
- unfinishedSlots = 0
- repeat with wSlot = 1 to count(holeData)
- slotAim = holeData[wSlot][1]
- slotDist = holeData[wSlot][2]
- slotCircle = holeData[wSlot][3]
- slotSpin = holeData[wSlot][4]
- slotShape = holeData[wSlot][5]
- slotStatus = holeData[wSlot][6]
- slotSpin = 0
- if slotStatus <> 0 then
- totalCompleted = totalCompleted + 1
- else
- unfinishedSlots = unfinishedSlots + 1
- end if
- spinAdjust = spinFactor[slotCircle]
- locY = integer(cos((slotAim + spinAdjust) * PI / 180) * -slotDist)
- locX = integer(sin((slotAim + spinAdjust) * PI / 180) * slotDist)
- wSprite = 30 + wSlot
- set the loc of sprite wSprite to the loc of sprite 5 + point(locX, locY)
- if reDraw = 1 then
- if slotStatus <> 0 then
- set the member of sprite wSprite to "Shape " & string(slotShape)
- else
- set the member of sprite wSprite to "Slot " & string(slotShape)
- end if
- end if
- sprite(wSprite).rotation = 0
- if (grabbedPiece <> 0) and (slotStatus = 0) then
- if pegData[grabbedPiece][4] = 0 then
- testLoc = pegData[grabbedPiece][1]
- testAim = pegData[grabbedPiece][2]
- testType = pegData[grabbedPiece][3]
- testAim = 0
- if findDistance(testLoc, the loc of sprite 5 + point(locX, locY)) <= 5 then
- locY1 = integer(cos(testAim * PI / 180) * -100)
- locX1 = integer(sin(testAim * PI / 180) * 100)
- locY2 = integer(cos((slotSpin + spinAdjust) * PI / 180) * -100)
- locX2 = integer(sin((slotSpin + spinAdjust) * PI / 180) * 100)
- if findDistance(point(locX1, locY1), point(locX2, locY2)) <= 25 then
- if slotShape = testType then
- pegData[grabbedPiece][4] = wSlot
- pegData[grabbedPiece][1] = point(-50, -50)
- holeData[wSlot][6] = grabbedPiece
- set the loc of sprite (100 + grabbedPiece) to point(-50, -50)
- grabbedPiece = 0
- gottaRedraw = 1
- end if
- end if
- end if
- end if
- end if
- end repeat
- if gottaRedraw = 1 then
- drawChart(totalCompleted * 100 / maximumPegs)
- playSound("drop_in_correct_placeholder", 3)
- end if
- end
-
- on drawpegs
- repeat with wPeg = 1 to count(pegData)
- if pegData[wPeg][4] = 0 then
- set the loc of sprite (100 + wPeg) to pegData[wPeg][1]
- set the member of sprite (100 + wPeg) to "Shape " & string(pegData[wPeg][3])
- sprite(100 + wPeg).rotation = 0
- sprite(100 + wPeg).locZ = 150
- next repeat
- end if
- parentSprite = 30 + pegData[wPeg][4]
- set the loc of sprite (100 + wPeg) to the loc of sprite parentSprite
- set the member of sprite (100 + wPeg) to "Shape " & string(pegData[wPeg][3])
- sprite(100 + wPeg).rotation = 0
- sprite(100 + wPeg).locZ = 100
- end repeat
- end
-
- on updatePeg
- if grabbedPiece <> 0 then
- wPeg = grabbedPiece
- if pegData[wPeg][4] = 0 then
- set the loc of sprite (100 + wPeg) to pegData[wPeg][1]
- set the member of sprite (100 + wPeg) to "Shape " & string(pegData[wPeg][3])
- sprite(100 + wPeg).rotation = 0
- else
- parentSprite = 30 + pegData[wPeg][4]
- set the loc of sprite (100 + wPeg) to the loc of sprite parentSprite
- set the member of sprite (100 + wPeg) to "Shape " & string(pegData[wPeg][3])
- sprite(100 + wPeg).rotation = sprite(parentSprite).rotation
- end if
- end if
- end
-