home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Magazine 28 Bonus / CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin / data / cnbalex.dir / 00143_Script_GameHandlers < prev    next >
Text File  |  1996-06-10  |  4KB  |  133 lines

  1. on initGame
  2.   global buttonList,paintingList,matchedPaintings,oldValue,disabledButtons
  3.   
  4.   set buttonList = [Circle:17,Triangle:18,Balanced:19,Unbalanced:20]
  5.   set paintingList = [pBalanced:11,pCircle:12,pTriangle:13,pUnbalanced:14]
  6.   set matchedPaintings = []
  7.   set disabledButtons = []
  8.   set oldValue = ""
  9.   
  10.   setPuppets buttonlist,TRUE
  11.   setPuppets paintingList, TRUE
  12. end
  13.  
  14.  
  15. on checkButton aButtonSprite,correctPainting
  16.   global disabledButtons,buttonSprite
  17.   set buttonSprite = aButtonSprite
  18.   if NOT inList (disabledButtons,aButtonSprite) then
  19.     processButton aButtonSprite,correctPainting
  20.   end if
  21.   
  22. end
  23.  
  24.  
  25. on processButton buttonSprite,correctPainting
  26.   global buttonList,paintingList,disabledButtons
  27.   
  28.   -- change te empty castMember of sprite aButton to the shape castMember
  29.   set aShape = string(getOne(buttonList,buttonSprite)) 
  30.   set the castNum of sprite buttonSprite to the number of cast aShape
  31.   updateStage
  32.   
  33.   -- Sprite's going to be moved so remember the starting location
  34.   set oldLocH = the locH of sprite buttonSprite
  35.   set oldLocV = the locV of sprite buttonSprite
  36.   set oldButtonPos = [oldLocH,oldLocV]
  37.   
  38.   -- Track sprite
  39.   repeat while the stillDown
  40.     set the locH of sprite buttonSprite to the mouseH 
  41.     set the locV of sprite buttonSprite to the mouseV
  42.     updateStage
  43.   end repeat
  44.   
  45.   -- find out which painting this shape is supposed to go to
  46.   set correctPaintingSprite = getAprop(paintingList,correctPainting)
  47.   
  48.   
  49.   -- perform the corresponding action when the shape is on the CORRECT painting...
  50.   if sprite buttonSprite WITHIN correctPaintingSprite then
  51.     correctPChoice buttonSprite,correctPainting
  52.     add(disabledButtons,buttonSprite) -- remember this shape is used so dont use it again
  53.   else resetSprite buttonSprite,oldButtonPos
  54.   
  55. end
  56.  
  57.  
  58. -- play animation that shows the shape "growing" on the painting
  59. on correctPChoice bSprite
  60.   global buttonList
  61.   -- get the property that corresponds to the spriteNumber
  62.   set paintingMarker = getOne(buttonList,bSprite)
  63.   
  64.   put "paintingMarker= "&paintingMarker
  65.   
  66.   go to string(paintingMarker)  
  67.   
  68. end
  69.  
  70.  
  71. -- bring button back to original state
  72. on resetSprite bSprite,oldLoc
  73.   go "Missed"
  74.   set the locH of sprite bSprite to getAt(oldLoc,1)
  75.   set the locV of sprite bSprite to getAt(oldLoc,2)
  76.   --set the castNum of sprite bSprite to the number of cast 23 -- an empty square
  77.   updateStage
  78.   
  79. end
  80.  
  81. -- handler showMarkedPainting gets called whenever the pb head jumps back to frame
  82. -- "start" after an anomation.It sets all sprites (containing paintings) in mPaintingsList
  83. -- to show their "matched" counterpart - i.e. te one with the shape on it
  84.  
  85. on showMarkedPainting mPaintingsList
  86.   global paintingList,oldValue
  87.   
  88.   if mPaintingsList <> [] then
  89.     --if getAt(mPaintingsList,count(mPaintingsList)) <> oldValue then
  90.     repeat with i = 1 to count(mPaintingsList)
  91.       set the castNum of sprite getAProp(paintingList,getAt(mPaintingsList,i)) ¼
  92. to cast (getAt(mPaintingsList,i)&" On 3")
  93.     end repeat
  94.   end if
  95.   
  96.   updateStage
  97.   
  98. end
  99.  
  100.  
  101. on grayOutButton
  102.   global buttonList,disabledButtons,buttonList
  103.   repeat with i = 1 to count(disabledButtons)
  104.     set disabledButton = getAt(disabledButtons,i)
  105.     set buttonName = getOne(buttonList,disabledButton)
  106.     set the castNum of sprite disabledButton to the number of cast (buttonName&"Button Inactive")
  107.     set the cursor of sprite disabledButton to -1
  108.   end repeat
  109.   
  110.   updateStage
  111.   
  112. end
  113.  
  114.  
  115. -- handler returnToStart shows the first frame and calls handle
  116. -- to gray the chosenbutton
  117. on returnToStart aPainting
  118.   global matchedPaintings,buttonSprite
  119.   if NOT voidp(aPainting) then add(matchedPaintings,aPainting)
  120.   go "Bal4ExST"
  121.   grayOutButton buttonSprite
  122.   
  123. end
  124.  
  125.  
  126. on goFrame aFrame
  127.   -- test if parameter is valid..
  128.   set validFrame = TRUE
  129.   if voidP(aFrame) OR aFrame = "" then set validFrame = FALSE
  130.   
  131.   if validFrame then go frame aframe
  132.   
  133. end