home *** CD-ROM | disk | FTP | other *** search
- property PEG_columns, PEG_rows, myHPegs, myVPegs, myAnimator, myButtons
- global gMyPegBoard, gConstrainSprite, gIsRunning, gHandCursor, gSpeedCntrSprite
-
- on new me
- set PEG_columns to 16
- set PEG_rows to 11
- set myButtons to 28
- puppetSprite(myButtons, 1)
- set myHPegs to []
- set count to 2
- setAt(myHPegs, 1, 48)
- repeat while count < PEG_columns
- set pos to 48 + ((count - 1) * 30)
- setAt(myHPegs, count, pos)
- set count to count + 1
- end repeat
- setAt(myHPegs, count, pos)
- set myVPegs to []
- set count to 2
- setAt(myVPegs, 1, 50)
- repeat while count < PEG_rows
- set pos to 50 + ((count - 1) * 30)
- setAt(myVPegs, count, pos)
- set count to count + 1
- end repeat
- setAt(myVPegs, count, pos)
- puppetSprite(gSpeedCntrSprite, 1)
- set the immediate of sprite gSpeedCntrSprite to 1
- set myAnimator to new(script "aAnimator")
- return me
- end
-
- on mClearPegs me
- mClearActors(myAnimator)
- set myAnimator to 0
- set myHPegs to 0
- set myVPegs to 0
- end
-
- on mSnapTo me, thePart
- global gConstrainSprite
- set aSprite to the clickOn
- if (aSprite > 4) and (aSprite < 22) then
- set the constraint of sprite aSprite to gConstrainSprite
- mFindNearestHPeg(me, aSprite)
- mFindNearestVPeg(me, aSprite)
- mBroadCastParts(myAnimator)
- if aSprite <= 8 then
- mSetAtributes(myAnimator, aSprite)
- end if
- end if
- end
-
- on mFindNearestHPeg me, aSprite
- global gConstrainSprite
- set continueSearch to 1
- set aHloc to the locH of sprite aSprite
- set count to PEG_columns - 1
- set pegLocUpper to getAt(myHPegs, count)
- set pegLocLower to getAt(myHPegs, count - 1)
- repeat while continueSearch and (count > 0)
- if (aHloc >= pegLocLower) and (aHloc <= pegLocUpper) then
- set continueSearch to 0
- end if
- if (count = 1) and continueSearch then
- set continueSearch to 0
- next repeat
- end if
- if continueSearch then
- set pegLocLower to getAt(myHPegs, count - 1)
- set pegLocUpper to getAt(myHPegs, count)
- set count to count - 1
- end if
- end repeat
- if (aHloc - pegLocLower) > (pegLocUpper - aHloc) then
- set the locH of sprite aSprite to pegLocUpper
- else
- set the locH of sprite aSprite to pegLocLower
- end if
- end
-
- on mFindNearestVPeg me, aSprite
- set count to PEG_rows - 1
- set aVloc to the locV of sprite aSprite
- set continueSearch to 1
- set pegLocUpper to getAt(myVPegs, count)
- set pegLocLower to getAt(myVPegs, count - 1)
- repeat while continueSearch and (count > 0)
- if (aVloc >= pegLocLower) and (aHloc <= pegLocUpper) then
- set continueSearch to 0
- end if
- if (count = 1) and continueSearch then
- set continueSearch to 0
- next repeat
- end if
- if continueSearch then
- set pegLocLower to getAt(myVPegs, count - 1)
- set pegLocUpper to getAt(myVPegs, count)
- set count to count - 1
- end if
- end repeat
- if (aVloc - pegLocLower) > (pegLocUpper - aVloc) then
- set the locV of sprite aSprite to pegLocUpper
- else
- set the locV of sprite aSprite to pegLocLower
- end if
- end
-
- on mSetSpeed me
- mSetSpeed(myAnimator)
- end
-
- on mMakeVacChute me
- mMakeVacChute(myAnimator)
- end
-
- on mStartMotor me
- mBroadCastParts(myAnimator)
- set the castNum of sprite myButtons to 164
- end
-
- on mStopMotor me
- set the castNum of sprite myButtons to 168
- end
-
- on mGetAnimator me
- return myAnimator
- end
-
- on mTestPartsPalletClick me, partNumber
- mCreatPart(myAnimator, partNumber)
- end
-
- on mBounceBall me
- mBounceBall(myAnimator)
- end
-
- on mResetCntrl me
- if gIsRunning then
- set the castNum of sprite myButtons to 164
- else
- set the castNum of sprite myButtons to 168
- end if
- updateStage()
- end
-
- on mGetMechSim me
- if gIsRunning then
- set the castNum of sprite myButtons to 163
- else
- set the castNum of sprite myButtons to 167
- end if
- updateStage()
- return mGetMechSim(myAnimator)
- end
-
- on mSetMechSim me
- if gIsRunning then
- set the castNum of sprite myButtons to 162
- else
- set the castNum of sprite myButtons to 166
- end if
- updateStage()
- mSetMechSim(myAnimator)
- end
-
- on mRotorRotation me
- stepFrame(myAnimator)
- end
-
- on mClearBoard me
- mClearAllParts(myAnimator)
- end
-