home *** CD-ROM | disk | FTP | other *** search
/ Computer Life: SuperPac / SuperPac (Computer Life Magazine)(Ziff-Davis)(1995).ISO / pc / demos / nile / senet.exe / senet.DXR / 00020_Senet Game Global Functions.ls < prev    next >
Encoding:
Text File  |  1995-05-04  |  11.9 KB  |  450 lines

  1. on startMovie
  2.   global RamsesWins, PlayerOneWins, PlayerTwoWins, WhoRolledLast, onIBM, timeCorrection
  3.   set onIBM to the machineType = 256
  4.   if onIBM then
  5.     set timeCorrection to 30
  6.   else
  7.     set timeCorrection to 0
  8.   end if
  9.   set RamsesWins to 0
  10.   set PlayerOneWins to 0
  11.   set PlayerTwoWins to 0
  12.   set WhoRolledLast to 2
  13.   set the keyDownScript to "VolumeKeyPressed the key"
  14. end
  15.  
  16. on checktimeFlash
  17.   global startTime, timeCorrection
  18.   if (the ticks - startTime) > (570 + timeCorrection) then
  19.     go("Flash")
  20.   end if
  21. end
  22.  
  23. on VolumeKeyPressed QtyChar
  24.   filterQuit(QtyChar)
  25.   set QtyCharCode to charToNum(QtyChar)
  26.   if (QtyCharCode >= 48) and (QtyCharCode <= 57) then
  27.     set QtyNum to value(QtyChar)
  28.     if QtyNum > 7 then
  29.       set QtyNum to 7
  30.     end if
  31.     set the soundLevel to QtyNum
  32.   end if
  33. end
  34.  
  35. on filterQuit keyPressed
  36.   global onIBM
  37.   if onIBM then
  38.     if the optionDown and (charToNum(keyPressed) = 27) then
  39.       quit()
  40.     end if
  41.     if the commandDown and (the keyCode = 12) then
  42.       quit()
  43.     end if
  44.   else
  45.     if the commandDown and (the keyCode = 12) then
  46.       quit()
  47.     end if
  48.   end if
  49. end
  50.  
  51. on debug theString
  52.   put theString
  53. end
  54.  
  55. on setListOfPuppetsTo theList, trueOrFalse
  56.   repeat with x = 1 to count(theList)
  57.     puppetSprite(getAt(theList, x), trueOrFalse)
  58.   end repeat
  59. end
  60.  
  61. on PauseForThis ticksToPause
  62.   set endTime to the ticks + ticksToPause
  63.   set currTime to the ticks
  64.   repeat while currTime < endTime
  65.     set currTime to the ticks
  66.   end repeat
  67. end
  68.  
  69. on setCountDownTimer ticksToWait
  70.   global endTime
  71.   set endTime to the ticks + ticksToWait
  72. end
  73.  
  74. on timeElapsed
  75.   global endTime
  76.   if the ticks > endTime then
  77.     return 1
  78.   else
  79.     return 0
  80.   end if
  81. end
  82.  
  83. on PLaySound WhichSound
  84.   puppetSound(WhichSound)
  85.   updateStage()
  86. end
  87.  
  88. on ShakeSprite
  89.   repeat with x = 1 to 10
  90.     set the locH of sprite the clickOn to the locH of sprite the clickOn + 10
  91.     updateStage()
  92.     set the locH of sprite the clickOn to the locH of sprite the clickOn - 10
  93.     updateStage()
  94.   end repeat
  95. end
  96.  
  97. on playClick HowMany
  98.   repeat with x = 1 to HowMany
  99.     puppetSound("Click.1")
  100.     updateStage()
  101.     repeat while soundBusy(1)
  102.     end repeat
  103.   end repeat
  104. end
  105.  
  106. on RamTaunt
  107.   global theSenetGame, lastBoardScore, numberRamsesTaunts, ramsesTauntList
  108.   if the computerPlayer of theSenetGame = 0 then
  109.     exit
  110.   end if
  111.   repeat while soundBusy(1)
  112.   end repeat
  113.   if random(680) < lastBoardScore then
  114.     if count(ramsesTauntList) = 0 then
  115.       repeat with x = 1 to numberRamsesTaunts
  116.         add(ramsesTauntList, x)
  117.       end repeat
  118.     end if
  119.     set soundNumber to random(count(ramsesTauntList))
  120.     set SoundFile to "RamsesTaunt." & getAt(ramsesTauntList, soundNumber)
  121.     deleteAt(ramsesTauntList, soundNumber)
  122.     puppetSound(SoundFile, 1)
  123.     updateStage()
  124.   end if
  125.   repeat while soundBusy(1)
  126.   end repeat
  127. end
  128.  
  129. on RamAttack
  130.   global theSenetGame, lastBoardScore, numberRamsesAttack, ramsesAttackList
  131.   if the computerPlayer of theSenetGame = 0 then
  132.     exit
  133.   end if
  134.   repeat while soundBusy(1)
  135.   end repeat
  136.   if random(680) < lastBoardScore then
  137.     if count(ramsesAttackList) = 0 then
  138.       repeat with x = 1 to numberRamsesAttack
  139.         add(ramsesAttackList, x)
  140.       end repeat
  141.     end if
  142.     set soundNumber to random(count(ramsesAttackList))
  143.     set SoundFile to "RamsesAttack." & getAt(ramsesAttackList, soundNumber)
  144.     deleteAt(ramsesAttackList, soundNumber)
  145.     puppetSound(SoundFile, 1)
  146.     updateStage()
  147.   end if
  148.   repeat while soundBusy(1)
  149.   end repeat
  150. end
  151.  
  152. on RamPissed
  153.   global theSenetGame, lastBoardScore, numberRamsesPissed, ramsesPissedList
  154.   if the computerPlayer of theSenetGame = 0 then
  155.     exit
  156.   end if
  157.   repeat while soundBusy(1)
  158.   end repeat
  159.   if random(680) > lastBoardScore then
  160.     if count(ramsesPissedList) = 0 then
  161.       repeat with x = 1 to numberRamsesPissed
  162.         add(ramsesPissedList, x)
  163.       end repeat
  164.     end if
  165.     set soundNumber to random(count(ramsesPissedList))
  166.     set SoundFile to "RamsesPissed." & getAt(ramsesPissedList, soundNumber)
  167.     deleteAt(ramsesPissedList, soundNumber)
  168.     puppetSound(SoundFile, 1)
  169.     updateStage()
  170.   end if
  171.   repeat while soundBusy(1)
  172.   end repeat
  173. end
  174.  
  175. on RamYourMove
  176.   global theSenetGame, numberRamsesYourMove, ramsesYourMoveList
  177.   if the computerPlayer of theSenetGame = 0 then
  178.     exit
  179.   end if
  180.   repeat while soundBusy(1)
  181.   end repeat
  182.   if random(6) = 6 then
  183.     if count(ramsesYourMoveList) = 0 then
  184.       repeat with x = 1 to numberRamsesYourMove
  185.         add(ramsesYourMoveList, x)
  186.       end repeat
  187.     end if
  188.     set soundNumber to random(count(ramsesYourMoveList))
  189.     set SoundFile to "RamsesYourMove." & getAt(ramsesYourMoveList, soundNumber)
  190.     deleteAt(ramsesYourMoveList, soundNumber)
  191.     puppetSound(SoundFile, 1)
  192.     updateStage()
  193.   end if
  194. end
  195.  
  196. on RamDontCheat
  197.   repeat while soundBusy(1)
  198.   end repeat
  199.   if random(10) = 10 then
  200.     PLaySound("Don'tCheat")
  201.   end if
  202. end
  203.  
  204. on HelpToggle
  205.   puppetSound("SlideUp")
  206.   updateStage()
  207.   if the locV of sprite 38 = 409 then
  208.     set VMount to 10
  209.   else
  210.     set VMount to -10
  211.   end if
  212.   repeat with x = 1 to 15
  213.     set the locV of sprite 38 to the locV of sprite 38 + VMount
  214.     updateStage()
  215.   end repeat
  216.   repeat while soundBusy(1)
  217.     updateStage()
  218.   end repeat
  219.   if the locV of sprite 38 = 409 then
  220.     puppetSound("Help.aif")
  221.   end if
  222. end
  223.  
  224. on PlayerToggle
  225.   repeat while soundBusy(1)
  226.     updateStage()
  227.   end repeat
  228.   puppetSound(0)
  229.   puppetSound("SlideUp")
  230.   updateStage()
  231.   if the locV of sprite 39 = 409 then
  232.     set VMount to 10
  233.     set the visible of sprite 40 to 0
  234.     set the visible of sprite 41 to 0
  235.   else
  236.     set VMount to -10
  237.   end if
  238.   repeat with x = 1 to 15
  239.     set the locV of sprite 39 to the locV of sprite 39 + VMount
  240.     updateStage()
  241.   end repeat
  242.   if VMount < 0 then
  243.     set the visible of sprite 40 to 1
  244.     set the visible of sprite 41 to 1
  245.   end if
  246.   updateStage()
  247.   repeat while soundBusy(1)
  248.     updateStage()
  249.   end repeat
  250.   sound stop 1
  251. end
  252.  
  253. on EndTheGame whitePieces, blackPieces, compPlayer
  254.   global RamsesWins, PlayerOneWins, PlayerTwoWins, returnToMovieStorage
  255.   if compPlayer > 0 then
  256.     if whitePieces = 0 then
  257.       if the text of cast "Player 1" = "Light" then
  258.         if compPlayer = 1 then
  259.           set playerWon to 0
  260.         else
  261.           set playerWon to 1
  262.         end if
  263.       else
  264.         if compPlayer = 2 then
  265.           set playerWon to 0
  266.         else
  267.           set playerWon to 2
  268.         end if
  269.       end if
  270.     else
  271.       if the text of cast "Player 1" = "Dark" then
  272.         if compPlayer = 1 then
  273.           set playerWon to 0
  274.         else
  275.           set playerWon to 1
  276.         end if
  277.       else
  278.         if compPlayer = 2 then
  279.           set playerWon to 0
  280.         else
  281.           set playerWon to 2
  282.         end if
  283.       end if
  284.     end if
  285.     if playerWon = 0 then
  286.       set RamsesWins to RamsesWins + 1
  287.       set the text of cast "TheMsg" to "Ramses triumphs again!"
  288.       if RamsesWins > 1 then
  289.         puppetSound("#Ramses[2nd+++]Win.aif")
  290.       else
  291.         puppetSound("##RamsesWins/SFX")
  292.       end if
  293.     else
  294.       if voidp(returnToMovieStorage) then
  295.         set returnToMovieStorage to [:]
  296.       end if
  297.       setaProp(returnToMovieStorage, #senetBeat, 1)
  298.       if playerWon = 1 then
  299.         set PlayerOneWins to PlayerOneWins + 1
  300.       else
  301.         set PlayerTwoWins to PlayerTwoWins + 1
  302.       end if
  303.       set the text of cast "TheMsg" to "You beat Ramses!"
  304.       if getaProp(returnToMovieStorage, #senetBeat) then
  305.         puppetSound("###Ramses1stLoss.aif")
  306.       else
  307.         if PlayerTwoWins > 1 then
  308.           puppetSound("YouBeatRamsesAgain")
  309.         else
  310.           puppetSound("###Ramses1stLoss.aif")
  311.         end if
  312.       end if
  313.     end if
  314.     updateStage()
  315.     repeat while soundBusy(1)
  316.     end repeat
  317.   else
  318.     if whitePieces = 0 then
  319.       if the text of cast "Player 1" = "Light" then
  320.         set playerWon to 1
  321.       else
  322.         set playerWon to 2
  323.       end if
  324.     else
  325.       if the text of cast "Player 1" = "Dark" then
  326.         set playerWon to 1
  327.       else
  328.         set playerWon to 2
  329.       end if
  330.     end if
  331.     if playerWon = 1 then
  332.       set PlayerOneWins to PlayerOneWins + 1
  333.       set the text of cast "TheMsg" to "Player 1 wins!"
  334.     else
  335.       set PlayerTwoWins to PlayerTwoWins + 1
  336.       set the text of cast "TheMsg" to "Player 2 wins!"
  337.     end if
  338.     puppetSound("##RamsesWins/SFX")
  339.     updateStage()
  340.     repeat while soundBusy(1)
  341.     end repeat
  342.   end if
  343. end
  344.  
  345. on StartTheGame
  346.   global theSenetGame, aFirstPlayerSelected, aMoveMade, gameOver, numberRamsesAttack, numberRamsesTaunts, numberRamsesPissed, numberRamsesYourMove, ramsesAttackList, ramsesTauntList, ramsesPissedList, ramsesYourMoveList
  347.   set theSenetGame to birth(script "Senet Game Parent")
  348.   set aFirstPlayerSelected to 0
  349.   set aMoveMade to 1
  350.   set numberRamsesTaunts to 21
  351.   set numberRamsesAttack to 29
  352.   set numberRamsesPissed to 37
  353.   set numberRamsesYourMove to 16
  354.   set ramsesTauntList to []
  355.   set ramsesAttackList to []
  356.   set ramsesPissedList to []
  357.   set ramsesYourMoveList to []
  358.   repeat with x = 1 to numberRamsesTaunts
  359.     add(ramsesTauntList, x)
  360.   end repeat
  361.   repeat with x = 1 to numberRamsesAttack
  362.     add(ramsesAttackList, x)
  363.   end repeat
  364.   repeat with x = 1 to numberRamsesPissed
  365.     add(ramsesPissedList, x)
  366.   end repeat
  367.   repeat with x = 1 to numberRamsesYourMove
  368.     add(ramsesYourMoveList, x)
  369.   end repeat
  370.   puppetSprite(23, 1)
  371.   puppetSprite(24, 1)
  372.   puppetSprite(38, 1)
  373.   puppetSprite(39, 1)
  374.   puppetSprite(40, 1)
  375.   puppetSprite(41, 1)
  376.   set the visible of sprite 40 to 0
  377.   set the visible of sprite 41 to 0
  378.   set the castNum of sprite 40 to the number of cast "Ramses Button Up"
  379.   set the castNum of sprite 41 to the number of cast "Player Button Up"
  380.   set the locH of sprite 40 to 157
  381.   set the locV of sprite 40 to 403
  382.   set the locH of sprite 41 to 474
  383.   set the locV of sprite 41 to 403
  384.   set the visible of sprite 48 to 0
  385.   repeat with x = 4 to 18
  386.     set the visible of sprite x to 1
  387.   end repeat
  388.   set the text of cast "TheMsg" to EMPTY
  389.   repeat with x = 1 to 5
  390.     set the visible of sprite getAt(the blackPiecesSpriteList of theSenetGame, x) to 1
  391.     set the blend of sprite getAt(the blackPiecesSpriteList of theSenetGame, x) to 100
  392.     set the visible of sprite getAt(the whitePiecesSpriteList of theSenetGame, x) to 1
  393.     set the blend of sprite getAt(the whitePiecesSpriteList of theSenetGame, x) to 100
  394.   end repeat
  395.   set the visible of sprite 23 to 0
  396.   set the visible of sprite 24 to 0
  397. end
  398.  
  399. on resetDice Hloc
  400.   global theSenetGame
  401.   repeat with x = 1 to count(the diceSpriteList of theSenetGame)
  402.     set the locH of sprite getAt(the diceSpriteList of theSenetGame, x) to Hloc + (x * 25)
  403.     set the castNum of sprite getAt(the diceSpriteList of theSenetGame, x) to the number of cast "Dice Down.1"
  404.     updateStage()
  405.   end repeat
  406. end
  407.  
  408. on hopPiece fromSquare, toSquare, spriteToHop
  409.   global theSenetGame
  410.   set fromLoc to getAt(the squareLocList of theSenetGame, fromSquare)
  411.   set toLoc to getAt(the squareLocList of theSenetGame, toSquare)
  412.   set fromH to getAt(fromLoc, 1)
  413.   set fromV to getAt(fromLoc, 2)
  414.   set toH to getAt(toLoc, 1)
  415.   set toV to getAt(toLoc, 2)
  416.   if toV = fromV then
  417.     set horizon to abs(fromH - toH) / 2
  418.     if fromH < toH then
  419.       repeat with x = fromH to toH
  420.         set the locH of sprite spriteToHop to x
  421.         set the locV of sprite spriteToHop to toV - (horizon - abs(horizon - (x - fromH)))
  422.         updateStage()
  423.       end repeat
  424.     else
  425.       repeat with x = fromH down to toH
  426.         set the locH of sprite spriteToHop to x
  427.         set the locV of sprite spriteToHop to toV - (horizon - abs(horizon - (x - toH)))
  428.         updateStage()
  429.       end repeat
  430.     end if
  431.   else
  432.     set horizon to abs(fromV - toV) / 2
  433.     if fromV < toV then
  434.       repeat with y = fromV to toV
  435.         set the locV of sprite spriteToHop to y
  436.         set the locH of sprite spriteToHop to toH - (horizon - abs(horizon - (y - fromV)))
  437.         updateStage()
  438.       end repeat
  439.     else
  440.       repeat with y = fromV down to toV
  441.         set the locV of sprite spriteToHop to y
  442.         set the locH of sprite spriteToHop to toH - (horizon - abs(horizon - (y - toV)))
  443.         updateStage()
  444.       end repeat
  445.     end if
  446.   end if
  447.   puppetSound("click.1")
  448.   updateStage()
  449. end
  450.