home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Today - The Disc! 22 / cdrt22.iso / pc / bugbook / puzzle.dir / 00083_Script_movie2 < prev    next >
Text File  |  1995-06-26  |  16KB  |  509 lines

  1. ------------------------------------------------------------------------
  2. -- CODE FOR TIMEOUT SCRIPT
  3. ------------------------------------------------------------------------
  4. on doTimeOut
  5.   global localDir
  6.   go "start" of movie localDir&"BugDemo.dir"
  7. end doTimeOut
  8. ------------------------------------------------------------------------
  9.  
  10.  
  11. ------------------------------------------------------------------------
  12. -- CODE FOR ANSON TALKING
  13. ------------------------------------------------------------------------
  14. on ansonAction
  15.   
  16.   ------------------------------------------------------------------------
  17.   --NOTE: This code assumes that you have put some sounds in soundList
  18.   ------------------------------------------------------------------------
  19.   
  20.   global ansonNum,ansonMoves,ansonSprite,soundList,soundListNum,ansonTalking
  21.   
  22.   if ansonNum = 0 then
  23.     set soundListNum = 1
  24.     set ansonNum = 1
  25.     --    puppetTempo 22
  26.     set the loch of sprite ansonSprite = 101
  27.     set the locv of sprite ansonSprite = 459
  28.     set the stretch of sprite ansonSprite = FALSE
  29.     playAnsonSound(getAt(soundList,soundListNum))
  30.     
  31.     set tmpCast = "An-"&string(getAt(ansonMoves,ansonNum))
  32.     
  33.     set the castNum of sprite ansonSprite = the number of cast tmpCast
  34.     --    put "init ",tmpCast
  35.     
  36.   else
  37.     if soundBusy(2) then
  38.       
  39.       set ansonNum = ansonNum +1
  40.       if ansonNum > (count(ansonMoves)) then set ansonNum = 1
  41.       set tmpCast = "An-"&string(getAt(ansonMoves,ansonNum))
  42.       
  43.       set the castNum of sprite ansonSprite = the number of cast tmpCast
  44.       --      put "continue ",tmpCast
  45.       
  46.     else
  47.       set soundListNum=soundListNum+1
  48.       if (soundListNum > (count(soundList))) then
  49.         
  50.         set tmpCast = "An-4"
  51.         
  52.         set the castNum of sprite ansonSprite = the number of cast tmpCast
  53.         set ansonNum = 0
  54.         set ansonTalking = FALSE
  55.         --        put "done ",tmpCast
  56.         
  57.         --        puppetTempo 8
  58.       else
  59.         playAnsonSound(getAt(soundList,soundListNum))
  60.         
  61.         set tmpCast = "An-4"
  62.         
  63.         set the castNum of sprite ansonSprite = the number of cast tmpCast
  64.         --        put "next sound ",tmpCast
  65.       end if
  66.       
  67.     end if
  68.   end if
  69.   updateStage
  70. end ansonAction
  71.  
  72.  
  73.  
  74.  
  75. on ansonOff
  76.   global ansonTalking,ansonNum,ansonSprite
  77.   sound stop 1
  78.   sound stop 2
  79.   set ansonTalking=FALSE
  80.   set ansonNum = 0
  81.   set the loch of sprite ansonSprite = -100
  82.   set the locv of sprite ansonSprite = -100
  83.   set tmpCast = "An-4"
  84.   --  puppetTempo 8
  85.   updateStage
  86. end ansonOff
  87.  
  88.  
  89.  
  90. ------------------------------------------------------------------------
  91.  
  92.  
  93. -- -- *********************************************************
  94. -- -- Name:playAnsonSound
  95. -- -- Description: plays an aif sound of the drive.  
  96.  
  97. -- -- Example: 
  98. -- -- *********************************************************
  99. on playAnsonSound FileNme
  100.   global localDir
  101.   if the machineType=256 then
  102.     sound playFile 2, localDir&"GameSnd\" &FileNme&".aif"
  103.   else
  104.     sound playFile 2,localDir&"GameSnd:" &FileNme&".aif"
  105.   end if
  106.   
  107. end  playAnsonSound
  108.  
  109.  
  110.  
  111.  
  112.  
  113. on recreate
  114.   global movingPiece,currPuzzle,currPiece,A42Puzzle
  115.   set tolerance=8
  116.   set movingPiece=45
  117.   puppetSprite movingPiece,TRUE
  118.   --  set the moveableSprite of sprite movingPiece to TRUE
  119.   set currPuzzle=A42Puzzle
  120.   set currPiece=1
  121. end recreate
  122.  
  123.  
  124.  
  125. on startGame
  126.   global allStartList, foundList
  127.   --  puppetSprite 1, TRUE
  128.   set start42=[point(320, 219), point(590, 216), point(567, 373), point(612, 373), point(567, 335), point(612, 335), point(567, 297), point(612, 297), point(567, 259), point(612, 259), point(567, 411), point(612, 411), point(567, 175), point(612, 175), point(567, 137), point(612, 137), point(567, 99), point(612, 99), point(567, 61), point(612, 61), point(567, 23), point(612, 23), point(49, 216), point(26, 373), point(71, 373), point(26, 335), point(71, 335), point(26, 297), point(71, 297), point(26, 259), point(71, 259), point(26, 411), point(71, 411), point(26, 175), point(71, 175), point(26, 137), point(71, 137), point(26, 99), point(71, 99), point(26, 61), point(71, 61), point(26, 23), point(71, 23)]
  129.   
  130.   
  131.   set start20=[point(320, 219), point(606, 28), point(572, 69), point(606, 111), point(572, 153), point(606, 196), point(572, 238), point(606, 281), point(572, 323), point(606, 365), point(572, 408), point(33, 28), point(67, 69), point(33, 111), point(67, 153), point(33, 196), point(67, 238), point(33, 281), point(67, 323), point(33, 365), point(67, 408)]
  132.   set allStartList=[start20,start42]
  133.   
  134.   set foundList=[]
  135. end startGame
  136.  
  137.  
  138. on ReturnMouseLoc
  139.   global movingPiece
  140.   set tempPoint=point(the locH of sprite the clickOn, the locV of sprite the clickOn)
  141.   return tempPoint
  142. end returntempPoint
  143.  
  144. ----------------------------------------
  145. ------PuzzleList =1.puzzlePieceName,2.spriteNo,3.locPoint,4.startPoint,5.startSize,6.found
  146. ----------------------------------------
  147. on checkLoc
  148.   
  149.   global currHV,hyp,tolerance,currPuzzle,currPiece,movingPiece,GameAnimation,countPieces,currCount
  150.   
  151.   if not(currPiece>1 and currPiece<44) then ABORT
  152.   -- if (getAt(getAt(currPuzzle,currPiece),6)=1) then ABORT
  153.   
  154.   --set currHV=returnMouseLoc()
  155.   put the locH of sprite movingPiece into currH
  156.   put the locV of sprite movingPiece into currV
  157.   put the locH of getAt(getAt(currPuzzle,currPiece),3) into lockH
  158.   put the locV of getAt(getAt(currPuzzle,currPiece),3) into lockV
  159.   
  160.   set hyp= sqrt((currH-lockH)*(currH-lockH)+(currV-lockV)*(currV-lockV))
  161.   
  162.   if hyp<=tolerance then 
  163.     puppetSound "CONNECT"
  164.     -- --can opt to it this way
  165.     set the locV of sprite currPiece=the locV of getAt(getAt(currPuzzle,currPiece),3)
  166.     set the locH of sprite currPiece=the locH of getAt(getAt(currPuzzle,currPiece),3)
  167.     set the stretch of sprite currPiece to FALSE
  168.     
  169.     -- -- puppetSprite currPiece,FALSE
  170.     set the locV of sprite movingPiece=463
  171.     set the locH of sprite movingPiece=102
  172.     set the castNum of sprite movingPiece=the number of cast "puzzlePart"
  173.     set the stretch of sprite movingPiece to FALSE
  174.     
  175.     set currCount=currCount+1
  176.     --put (getAT(currPuzzle,currPiece))
  177.     setAt(getAt(currPuzzle,currPiece),6,1)
  178.     updateStage
  179.   else
  180.     if currH>600 or currV<-18 then
  181. --      puppetSound "flyback.aif"
  182.       if currH>600 and currV>=-18 then
  183.         set the locH of sprite movingPiece to 565
  184.       else if currH<=600 and currV<-18 then 
  185.         set the locV of sprite movingPiece to 65
  186.       else
  187.         set the locH of sprite movingPiece to 565
  188.         set the locV of sprite movingPiece to 65
  189.       end if
  190.     end  if
  191.     
  192.     if currH>600 or currV>465 then
  193. --      puppetSound "flyback.aif"
  194.       if currH>600 and currV<=465 then
  195.         set the locH of sprite movingPiece to 565
  196.       else if currH<600 and currV>465 then 
  197.         set the locV of sprite movingPiece to 373
  198.       else
  199.         set the locH of sprite movingPiece to 565
  200.         set the locV of sprite movingPiece to 373
  201.       end if
  202.     end  if
  203.     
  204.     if currH<-18 or currV<-18 then
  205. --      puppetSound "flyback.aif"
  206.       if currH<-18 and currV>=-18 then
  207.         set the locH of sprite movingPiece to 65
  208.       else if currH>=-18 and currV<-18 then 
  209.         set the locV of sprite movingPiece to 65
  210.       else
  211.         set the locH of sprite movingPiece to 65
  212.         set the locV of sprite movingPiece to 65
  213.       end if
  214.     end  if
  215.     
  216.     if currH<-18 or currV>465 then
  217. --      puppetSound "flyback.aif"
  218.       if currH<-18 and currV<=465 then
  219.         set the locH of sprite movingPiece to 65
  220.       else if currH>=-18 and currV>465 then 
  221.         set the locV of sprite movingPiece to 373
  222.       else
  223.         set the locH of sprite movingPiece to 65
  224.         set the locV of sprite movingPiece to 373
  225.       end if
  226.     end  if
  227.     updateStage
  228.   end if
  229.   
  230.   
  231.   
  232.   
  233.   if currCount=countPieces then
  234.     repeat with tempspriteNum = 2 to 43
  235.       set the puppet of sprite (tempspriteNum) to FALSE
  236.     end repeat
  237.     puppetSprite movingPiece,FALSE
  238.     set the mouseUpScript=""
  239.     go  (GameAnimation&".Animation")
  240.     puppetSound "forward.aif"
  241.   end if
  242.   
  243. end checkLoc
  244.  
  245. ------------------------------------------------------------------------ 
  246. -- CODE FOR DEPRESSED BACK BUTTON & SOUND
  247. ------------------------------------------------------------------------ 
  248. on DepressedButtonDown NeedbuttonName,NeedSpriteNum,NeedSound
  249.   sound stop 1
  250.   puppetSound NeedSound  
  251.   puppetSprite NeedSpriteNum,TRUE
  252.   set the castNum of sprite NeedSpriteNum = the number of cast NeedbuttonName
  253.   updateStage
  254.   startTimer
  255.   repeat while soundBusy(1)
  256.     nothing 
  257.   end repeat
  258.   puppetSound 0
  259.   puppetSprite NeedSpriteNum,FALSE
  260.   updateStage
  261. end  DepressedButtonDown
  262. ------------------------------------------------------------------------
  263.  
  264.  
  265.  
  266.  
  267. ----------------------------------------
  268. ------PuzzleList =1.puzzlePieceName,2.spriteNo,3.locPoint,4.startPoint,5.startSize,6.found
  269. ----------------------------------------
  270. on createPiece tempSprite
  271.   
  272.   global currPuzzle,currPiece, movingPiece,currPuzzle,tempPiece
  273.   put tempSprite into tempPiece
  274.   put the mouseH into currMouseH
  275.   put the mouseV into currMouseV
  276.   
  277.   
  278.   if not(tempPiece=currPiece)  then
  279.     if sprite 45 within 44 then
  280.       puppetSound "flyback.aif"
  281.       updateStage
  282.     end if
  283.     
  284.     
  285.     set the castNum of sprite movingPiece to cast getAt(getAt(currPuzzle,tempPiece),1)
  286.     set the stretch of sprite movingPiece to FALSE
  287.     set the locV of sprite movingPiece=the locV of getAt(getAt(currPuzzle,tempPiece),4)
  288.     set the locH of sprite movingPiece=the locH of getAt(getAt(currPuzzle,tempPiece),4)
  289.     
  290.     set the locV of sprite tempPiece=-100
  291.     set the locH of sprite tempPiece=-100
  292.     updateStage
  293.     
  294.     repeat while soundBusy(1)
  295.       nothing
  296.     end repeat
  297.     
  298.     
  299.     
  300.     if currPiece>1 and not(getAt(getAt(currPuzzle,currPiece),6)=1) then
  301.       
  302.       set the locV of sprite currPiece=the locV of getAt(getAt(currPuzzle,currPiece),4)
  303.       set the locH of sprite currPiece= the locH of getAt(getAt(currPuzzle,currPiece),4)
  304.     end if
  305.     put tempPiece into currPiece
  306.     puppetSound "mouse.aif"
  307.     updateStage
  308.     
  309.     set deltaH=(currMouseH-the loch of getAt(getAt(currPuzzle,currPiece),4))
  310.     set deltav=(currMouseV-the locv of getAt(getAt(currPuzzle,currPiece),4))
  311.     -- --move sprite
  312.     repeat while the stillDown
  313.       set currH=the mouseh-deltah
  314.       set currV=the mousev-deltav
  315.       set the loch of sprite movingPiece=currh
  316.       set the locv of sprite movingPiece=currv
  317.       updateStage
  318.     end repeat
  319.   end if
  320.   
  321. end createPuzzlePiece
  322.  
  323.  
  324. on createNewGame
  325.   global foundList,currStart, currPuzzle, countPieces
  326.   deleteAt currStart,1
  327.   
  328.   repeat with x=2 to countPieces+1
  329.     if x = 1 then nothing
  330.     
  331.     set tempStart=random(count(currStart))
  332.     setAt getAt(currPuzzle, x),4,getAt(currStart,tempstart)
  333.     
  334.     
  335.     puppetSprite (x),TRUE
  336.     
  337.     set the locV of sprite x to the locV of getAt(currStart,tempstart)
  338.     set the locH of sprite x to the locH of getAt(currStart,tempstart)
  339.     set the stretch of sprite x to TRUE
  340.     set the width of sprite x to the locH of getAt(getAt(currPuzzle,x),5)
  341.     set the height of sprite x to the locV of getAt(getAt(currPuzzle,x),5)
  342.     deleteAt currStart,tempStart
  343.     
  344.   end repeat
  345.   updateStage
  346.   
  347.   
  348.   
  349. end createNewGame
  350.  
  351.  
  352.  
  353.  
  354.  
  355. ------------------------------------------------------------------------
  356. -- CODE FOR ? BUTTONS & SOUND
  357. ------------------------------------------------------------------------
  358. on questionDown
  359.   global downSprite
  360.   sound stop 1
  361.   puppetSound "help"  
  362.   
  363.   set the castNum of sprite downSprite = the number of cast "?Down"
  364.   set the loch of sprite downSprite = 20
  365.   set the locv of sprite downSprite = 459
  366.   set the stretch of sprite downSprite = FALSE
  367.   updateStage
  368.   repeat while soundBusy(1)
  369.     --
  370.   end repeat
  371.   puppetSound 0
  372.   set the loch of sprite downSprite = -100
  373.   set the locv of sprite downSprite = -100
  374.   updateStage
  375. end questionDown
  376.  
  377. ------------------------------------------------------------------------ 
  378. -- CODE FOR DEPRESSED BACK BUTTON & SOUND
  379. ------------------------------------------------------------------------ 
  380. on backDown
  381.   global downSprite
  382.   sound stop 1
  383.   puppetSound "back"  
  384.   puppetSprite downSprite,TRUE
  385.   set the castNum of sprite downSprite = the number of cast "returnDown"
  386.   set the loch of sprite downSprite = 619
  387.   set the locv of sprite downSprite = 459
  388.   set the stretch of sprite downSprite to FALSE
  389.   updateStage
  390.   repeat while soundBusy(1)
  391.     nothing 
  392.   end repeat
  393.   puppetSound 0
  394.   set the loch of sprite downSprite = -100
  395.   set the locv of sprite downSprite = -100
  396.   updateStage
  397.   
  398. end  backDown
  399.  
  400. on puzzleDown
  401.   global downSprite
  402.   sound stop 1
  403.   sound stop 2
  404.   puppetSound "fun2"  
  405.   puppetSprite downSprite,TRUE
  406.   set the castNum of sprite downSprite = the number of cast "hintdown"
  407.   set the loch of sprite downSprite = 555
  408.   set the locv of sprite downSprite = 462
  409.   set the stretch of sprite downSprite to FALSE
  410.   updateStage
  411.   repeat while soundBusy(1)
  412.     nothing 
  413.   end repeat
  414.   puppetSound 0
  415.   set the loch of sprite downSprite = -100
  416.   set the locv of sprite downSprite = -100
  417.   updateStage
  418.   
  419. end  puzzleDown
  420.  
  421.  
  422.  
  423.  
  424.  
  425. -- -- *********************************************************
  426. -- -- this is only temp to create all the lists neccessary
  427.  
  428. -- -- *********************************************************
  429.  
  430. ----------------------------------------
  431. ------get the location of the sprite(startLoc,FinishLoc)
  432. ----------------------------------------
  433. on createPuzzleInfo currAmount
  434.   set tempList=[]
  435.   repeat with x=1 to currAmount
  436.     add tempList,point(the locH of sprite x, the locV of sprite x)
  437.   end repeat
  438.   Return tempList
  439. end createPuzzleList
  440.  
  441. ----------------------------------------
  442. ------get the size of small piece
  443. ----------------------------------------
  444.  
  445. on createsizeList currAmount
  446.   set tempList=[]
  447.   
  448.   repeat with x=1 to currAmount
  449.     add tempList,point(the width of sprite x,the height of sprite x)
  450.   end repeat
  451.   Return tempList
  452. end createPuzzleList
  453.  
  454.  
  455. ----------------------------------------
  456. ------create a name list of the castMembers of the puzzle
  457. ----------------------------------------
  458. on createNameList currAmount
  459.   set tempList=[]
  460.   
  461.   repeat with x=1 to currAmount
  462.     put the castNum  of sprite x into tempNum
  463.     add tempList,the name of cast tempNum
  464.   end repeat
  465.   Return tempList
  466. end createPuzzleList
  467.  
  468. ----------------------------------------
  469. ------PuzzleList =puzzlePieceName,spriteNo,locPoint,startPoint,startSize,found
  470. ----------------------------------------
  471. on createPuzzleList 
  472.   global locPoint,startSize,nameList
  473.   set temppuzzleList=[]
  474.   add temppuzzleList,["castName:string","spriteNumber:integer","LockedLocation:point","startPoint:point","startSize:point","found:boolean"]
  475.   repeat with x=2 to count(locPoint)
  476.     set tempList=[]
  477.     add tempList,GetAt(nameList,x)
  478.     add tempList,x
  479.     add tempList, getAT(locPoint,x)
  480.     add tempList, 0
  481.     add tempList, getAt(startSize,x)
  482.     add tempList,0
  483.     add temppuzzleList,tempList
  484.   end repeat
  485.   return temppuzzleList
  486. end puzzleList
  487.  
  488.  
  489. ------------------------------------------------------------------------ 
  490. -- CODE FOR DEPRESSED BUTTON & SOUND
  491. ------------------------------------------------------------------------ 
  492. on DepressedButton NeedbuttonName,NeedSpriteNum,NeedSound
  493.   sound stop 1
  494.   puppetSound NeedSound  
  495.   puppetSprite NeedSpriteNum,TRUE
  496.   set the castNum of sprite NeedSpriteNum = the number of cast NeedbuttonName
  497.   PuppetSoundStop()
  498.   puppetSprite NeedSpriteNum,FALSE
  499.   updateStage
  500. end  backDown
  501. ------------------------------------------------------------------------
  502. on PuppetSoundStop
  503.   updateStage
  504.   repeat while soundBusy(1)
  505.     --
  506.   end repeat
  507.   puppetSound 0
  508. end puppetSoundStop
  509.