home *** CD-ROM | disk | FTP | other *** search
/ Painter Bear's Language Bridge — Italian / Bridge_ponte_itialian.iso / pc / helpers / open.dxr / 00007_race.ls < prev    next >
Encoding:
Text File  |  2001-02-22  |  12.9 KB  |  441 lines

  1. global gFlshSpt, gStpLght, gCarSpt, gStBar, gFstLne, gLstLne, gFstObs, gLstObs, gSpdFactor, gLangSelect, gLangDirect, gRoadCollision, gRaceArch, gRacing, gFstRaceTime, gFstRaceScore, gNxtTime, gFlashTimer, gRaceTimer, gOnScnLst, gOffScnLst, gFloatDir, gScore, gCarBox
  2.  
  3. on goToRaceCut
  4.   go("preRace")
  5.   unloadMember(member "fart1", "click13")
  6.   unloadMember()
  7.   startTheTimer(gRaceTimer)
  8. end
  9.  
  10. on giveRaceInstructions
  11.   cursor(4)
  12.   go("race")
  13.   doMusicBtn()
  14.   doScore()
  15.   unloadMember(member "bridgecutscene")
  16.   preloadMember(member "roadcollision", "ocean 21")
  17.   set gRacing to 0
  18.   set gNxtTime to 0
  19.   popUp("arrow", "ok")
  20.   cursor(-1)
  21. end
  22.  
  23. on prepRAce
  24.   global gRacing, gFlashTimer, gRaceTimer, gOnScnLst, gOffScnLst, gLstObst, gFloatDir, gBackBtn
  25.   set gRacing to 1
  26.   setclock()
  27.   set the memberNum of sprite gBackBtn to the number of member "back up"
  28.   setUpSpriteLsts()
  29.   set gSpdFactor to 10
  30.   set gFloatDir to 0
  31.   set gLstObst to VOID
  32.   startTheTimer(gRaceTimer)
  33.   puppetSound(2, "light1")
  34.   puppetSound(1, "car 0")
  35. end
  36.  
  37. on setUpSpriteLsts
  38.   global gOnScnLst, gOffScnLst, gLstLne, gLstONLne, gObstLst, gFstObs
  39.   set gOnScnLst to []
  40.   set gOffScnLst to []
  41.   set gObstLst to []
  42.   repeat with X = gStBar to gLstObs
  43.     add(gOffScnLst, X)
  44.     if (X >= gFstObs) and (X <= gLstObs) then
  45.       add(gObstLst, X)
  46.     end if
  47.   end repeat
  48.   add(gOffScnLst, gRaceArch)
  49.   add(gOnScnLst, gStBar)
  50.   deleteAt(gOffScnLst, getPos(gOffScnLst, gStBar))
  51.   add(gOnScnLst, gRaceArch)
  52.   deleteAt(gOffScnLst, getPos(gOffScnLst, gRaceArch))
  53.   set lastLn to gFstLne + 5
  54.   repeat with X = gFstLne to lastLn
  55.     add(gOnScnLst, X)
  56.     deleteAt(gOffScnLst, getPos(gOffScnLst, X))
  57.   end repeat
  58.   set gLstONLne to lastLn
  59. end
  60.  
  61. on endRace
  62.   global gRacing, gFlashTimer, gRaceTimer
  63.   set gRacing to VOID
  64.   stopFlash()
  65.   stopTimer(gFlashTimer)
  66.   stopTimer(gRaceTimer)
  67. end
  68.  
  69. on goToPhaseTwo
  70.   global gRacing, gStpLght, gRaceTimer
  71.   set the memberNum of sprite gStpLght to the number of member "2 light"
  72.   set gRacing to 2
  73.   startTheTimer(gRaceTimer)
  74.   puppetSound(2, "light2")
  75. end
  76.  
  77. on goToPhaseThree
  78.   global gRacing, gStpLght, gRaceTimer, gMusOn
  79.   set the memberNum of sprite gStpLght to the number of member "3 light"
  80.   stopFlash()
  81.   set gRacing to 3
  82.   if gMusOn = 1 then
  83.     sound stop 3
  84.     puppetSound(3, "drive")
  85.   end if
  86.   startTheTimer(gRaceTimer)
  87.   puppetSound(2, "light3")
  88. end
  89.  
  90. on goToPhaseFour
  91.   global gRacing, gStpLght, gRaceTimer, gRoad, gStBar, gCarSpt, gMusOn
  92.   set the memberNum of sprite gStpLght to the number of member "1 light"
  93.   set the memberNum of sprite gCarSpt to the number of member "1 car"
  94.   set gRacing to 4
  95.   puppetSound(2, "light4")
  96.   puppetSound(1, "cheer")
  97.   if gMusOn = 1 then
  98.     sound stop 3
  99.     puppetSound(3, "loop")
  100.   end if
  101.   set gSpdFactor to 8
  102.   if gLangDirect = 1 then
  103.     set whichLang to "e"
  104.   else
  105.     set whichLang to gLangSelect
  106.   end if
  107.   set the memberNum of sprite gFlshSpt to the number of member ("1 " & whichLang & " bravoFlsh")
  108.   set the memberNum of sprite gStBar to the number of member "checker"
  109.   set the memberNum of sprite gRaceArch to the number of member "archend" of castLib "race"
  110.   set the locV of sprite gRaceArch to the top of sprite gRoad - (the height of sprite gRaceArch / 2)
  111.   set the locV of sprite gStBar to the top of sprite gRoad
  112.   startTheTimer(gFlashTimer)
  113.   updateStage()
  114. end
  115.  
  116. on goToPhaseFive
  117.   global gRacing, gRaceTimer, gBackBtn
  118.   set gRacing to 5
  119.   set the memberNum of sprite gBackBtn to the number of member "back flash up"
  120.   startTheTimer(gRaceTimer)
  121. end
  122.  
  123. on doSpeed whichWay
  124.   global gSpdFactor
  125.   case whichWay of
  126.     "1":
  127.       set gSpdFactor to max(0, gSpdFactor - 2)
  128.     "2":
  129.       set gSpdFactor to min(65, gSpdFactor + 2)
  130.   end case
  131.   doCarSnd()
  132. end
  133.  
  134. on doCarSnd
  135.   global gCarSnd
  136.   if gSpdFactor > 0 then
  137.     set whichCar to string(gSpdFactor)
  138.     if the number of chars in whichCar = 1 then
  139.       set whichCar to "car 0"
  140.     else
  141.       set whichCar to "car " & char 1 of whichCar
  142.     end if
  143.   else
  144.     set whichCar to "car 0"
  145.   end if
  146.   if gCarSnd <> whichCar then
  147.     puppetSound(1, whichCar)
  148.     set gCarSnd to whichCar
  149.   end if
  150. end
  151.  
  152. on moveCar whichDir
  153.   global gCarSpt, gRoad, gFloatDir, gRacing
  154.   if (gRacing = 3) or (gRacing = 8) or (gRacing = 9) then
  155.     case gRacing of
  156.       3:
  157.         set moveSpd to 7
  158.       8:
  159.         set moveSpd to 3
  160.       9:
  161.         set moveSpd to 3
  162.     end case
  163.     set lMax to integer(the left of sprite gRoadCollision + (the width of sprite gCarSpt / 2))
  164.     set rMax to integer(the right of sprite gRoadCollision - (the width of sprite gCarSpt / 2))
  165.     case whichDir of
  166.       "1":
  167.         set the locH of sprite gCarSpt to min(the locH of sprite gCarSpt + moveSpd, rMax)
  168.         set gFloatDir to 1
  169.       "2":
  170.         set the locH of sprite gCarSpt to max(the locH of sprite gCarSpt - moveSpd, lMax)
  171.         set gFloatDir to -1
  172.     end case
  173.     set the loc of sprite gCarBox to the loc of sprite gCarSpt
  174.   end if
  175. end
  176.  
  177. on raceObstacles
  178.   global gRacing, gRoad, gLstLne, gLstONLne, gSpdFactor, gLstObst, gObstLst, gStBar, gFloatDir, gRaceTimer
  179.   repeat with X = 1 to count(gOnScnLst)
  180.     set aSprite to getAt(gOnScnLst, X)
  181.     set the locV of sprite aSprite to the locV of sprite aSprite + gSpdFactor
  182.     if the top of sprite aSprite > (the bottom of sprite gRoad + 140) then
  183.       moveOffScreen(aSprite)
  184.     end if
  185.     if aSprite = gLstONLne then
  186.       set newLnLmt to (the height of sprite aSprite / 2) + 140
  187.       if the locV of sprite aSprite >= newLnLmt then
  188.         addNewLine()
  189.       end if
  190.     end if
  191.   end repeat
  192.   if (gRacing = 3) or (gRacing = 8) then
  193.     if gFloatDir = 1 then
  194.       set the locH of sprite gCarSpt to min(the locH of sprite gCarSpt + gFloatDir, the right of sprite gRoadCollision - (the width of sprite gCarSpt / 2))
  195.     else
  196.       set the locH of sprite gCarSpt to max(the locH of sprite gCarSpt + gFloatDir, the left of sprite gRoadCollision + (the width of sprite gCarSpt / 2))
  197.     end if
  198.     set the loc of sprite gCarBox to the loc of sprite gCarSpt
  199.     set obstLim to the height of sprite gFstObs + the height of sprite gCarSpt
  200.     if gSpdFactor < 10 then
  201.       set obFreq to 10
  202.     else
  203.       if (gSpdFactor >= 10) and (gSpdFactor < 50) then
  204.         set obFreq to 10
  205.       else
  206.         if (gSpdFactor >= 50) and (gSpdFactor < 70) then
  207.           set obFreq to 10
  208.         end if
  209.       end if
  210.     end if
  211.     set shouldI to random(obFreq)
  212.     if gLstObst = VOID then
  213.       set goAhead to 1
  214.     else
  215.       if (the top of sprite gLstObst >= obstLim) or (getPos(gOffScnLst, gLstObst) <> 0) then
  216.         set goAhead to 1
  217.       end if
  218.     end if
  219.     if (shouldI = 1) and (goAhead = 1) and (gObstLst <> []) then
  220.       addObstacle()
  221.     end if
  222.     if gRacing <> 8 then
  223.       repeat with X = 1 to count(gOnScnLst)
  224.         set aObst to getAt(gOnScnLst, X)
  225.         if sprite gCarBox intersects aObst and (aObst <= gLstObs) and (aObst >= gFstObs) then
  226.           if the name of member the memberNum of sprite aObst of castLib "race" = "RAMP" then
  227.             startRampHappiness()
  228.             exit repeat
  229.             next repeat
  230.           end if
  231.           doCollision()
  232.           exit repeat
  233.         end if
  234.       end repeat
  235.     end if
  236.   else
  237.     if gRacing = 4 then
  238.       set gSpdFactor to 8
  239.       set the locV of sprite gStBar to the locV of sprite gStBar + gSpdFactor
  240.       if the locV of sprite gStBar >= (the top of sprite gCarSpt - the height of sprite gRaceArch) then
  241.         set the locV of sprite gRaceArch to min(the top of sprite gRoad + (the height of sprite gRaceArch / 2), the locV of sprite gRaceArch + gSpdFactor)
  242.       end if
  243.       if sprite gCarSpt intersects gStBar then
  244.         goToPhaseFive()
  245.       end if
  246.     end if
  247.   end if
  248. end
  249.  
  250. on addObstacle
  251.   global gLstObst, gRoad, gCarSpt
  252.   set currObst to getAt(gObstLst, 1)
  253.   deleteAt(gObstLst, 1)
  254.   add(gOnScnLst, currObst)
  255.   deleteAt(gOffScnLst, getPos(gOffScnLst, currObst))
  256.   set gLstObst to currObst
  257.   if random(7) = 1 then
  258.     set the memberNum of sprite currObst to the number of member "RAMP"
  259.   else
  260.     set whichob to random(6)
  261.     set the memberNum of sprite currObst to the number of member (whichob & " obstacle")
  262.   end if
  263.   set the locV of sprite currObst to the top of sprite gRoad
  264.   if random(5) = 1 then
  265.     set whereH to the locH of sprite gCarSpt
  266.   else
  267.     set lMax to integer(the left of sprite gRoadCollision + (the width of sprite gCarSpt / 2))
  268.     set rMax to integer(the right of sprite gRoadCollision - (the width of sprite gCarSpt / 2))
  269.     set whereH to random(abs(lMax - rMax)) + (lMax - 1)
  270.   end if
  271.   set the locH of sprite currObst to whereH
  272. end
  273.  
  274. on moveOffScreen whichSprite
  275.   global gOnScnLst, gOffScnLst, gLstLne, gScore, gRacing
  276.   add(gOffScnLst, whichSprite)
  277.   deleteAt(gOnScnLst, getPos(gOnScnLst, whichSprite))
  278.   set the locV of sprite whichSprite to -100
  279.   if (gRacing = 3) or (gRacing = 8) then
  280.     if (whichSprite <= gLstLne) and (whichSprite >= gFstLne) then
  281.       set gScore to gScore + 2
  282.     else
  283.       if (whichSprite <= gLstObs) and (whichSprite >= gFstObs) then
  284.         set gScore to gScore + 10
  285.         add(gObstLst, whichSprite)
  286.       end if
  287.     end if
  288.     doScore()
  289.   end if
  290. end
  291.  
  292. on addNewLine
  293.   global gOnScnLst, gOffScnLst, gRoad, gLstLne, gLstONLne
  294.   repeat with z = 1 to count(gOffScnLst)
  295.     set aSprite to getAt(gOffScnLst, z)
  296.     if (aSprite <= gLstLne) and (aSprite >= gFstLne) then
  297.       add(gOnScnLst, aSprite)
  298.       deleteAt(gOffScnLst, getPos(gOffScnLst, aSprite))
  299.       set the locV of sprite aSprite to the top of sprite gRoad
  300.       set gLstONLne to aSprite
  301.       exit repeat
  302.     end if
  303.   end repeat
  304. end
  305.  
  306. on startRampHappiness
  307.   global gRacing, gFlashTimer, gScore, gSpdFactor, gRampTime
  308.   set gRacing to 8
  309.   set gRampTime to gSpdFactor
  310.   startTheTimer(gFlashTimer)
  311.   set gScore to gScore + 50
  312.   puppetSound(2, "rampSnd")
  313. end
  314.  
  315. on pursueRampHappiness
  316.   global gCarSpt
  317.   set foo to value(word 1 of the name of member the memberNum of sprite gCarSpt of castLib "race")
  318.   if foo <> 4 then
  319.     set foo to string(foo + 1)
  320.     set the memberNum of sprite gCarSpt to the number of member (foo & " car")
  321.   end if
  322. end
  323.  
  324. on stopRampHappiness
  325.   global gRacing, gFlashTimer
  326.   repeat with X = 4 down to 1
  327.     set the memberNum of sprite gCarSpt to the number of member (X & " car")
  328.     updateStage()
  329.   end repeat
  330.   set gRacing to 3
  331.   stopTimer(gFlashTimer)
  332.   puppetSound(2, "rampdn")
  333. end
  334.  
  335. on doCollision
  336.   global gScore, gFlashTimer, gStpLght, gRacing, gSpdFactor
  337.   set gScore to max(0, gScore - 10)
  338.   doScore()
  339.   set gSpdFactor to -10
  340.   doCarSnd()
  341.   set gRacing to 9
  342.   set the memberNum of sprite gStpLght to the number of member "2 light"
  343.   startTheTimer(gFlashTimer)
  344.   set whichBmp to random(3)
  345.   puppetSound(2, "bump" & whichBmp)
  346. end
  347.  
  348. on stopCollisionPunishment
  349.   global gRaceTimer, gStpLght, gRacing, gSpdFactor
  350.   set gRacing to 3
  351.   set gSpdFactor to 10
  352.   doCarSnd()
  353.   set the memberNum of sprite gStpLght to the number of member "3 light"
  354. end
  355.  
  356. on flashRaceSign
  357.   global gFlshSpt
  358.   set foo to the name of member the memberNum of sprite gFlshSpt of castLib "race"
  359.   set whichFlsh to word 1 of foo
  360.   if whichFlsh = "1" then
  361.     set whichFlsh to "2"
  362.   else
  363.     set whichFlsh to "1"
  364.   end if
  365.   put whichFlsh into word 1 of foo
  366.   set the memberNum of sprite gFlshSpt to the number of member foo
  367.   startTheTimer(gFlashTimer)
  368. end
  369.  
  370. on stopFlash
  371.   global gFlshSpt
  372.   stopTimer(gFlashTimer)
  373.   set foo to the name of member the memberNum of sprite gFlshSpt of castLib "race"
  374.   set whichFlsh to word 1 of foo
  375.   set whichFlsh to "2"
  376.   put whichFlsh into word 1 of foo
  377.   set the memberNum of sprite gFlshSpt to the number of member foo
  378. end
  379.  
  380. on setclock
  381.   global gSec, gMin, gRaceLength
  382.   set gRaceLength to 45
  383.   set gSec to gRaceLength
  384.   set gMin to 0
  385.   if the number of chars in string(gSec) = 1 then
  386.     set cosSec to "0" & gSec
  387.   else
  388.     set cosSec to gSec
  389.   end if
  390.   if the number of chars in string(gMin) = 1 then
  391.     set cosMin to "0" & gMin
  392.   else
  393.     set cosMin to gMin
  394.   end if
  395.   set timetext to cosMin & ":" & cosSec
  396.   set aSpt to gFstRaceTime
  397.   repeat with X = 1 to the number of chars in timetext
  398.     set aChar to char X of timetext
  399.     set the memberNum of sprite aSpt to the number of member ("time " & aChar)
  400.     set aSpt to aSpt + 1
  401.   end repeat
  402. end
  403.  
  404. on rollDownClock
  405.   global gSec, gMin, gNxtTime
  406.   set gNxtTime to gNxtTime + 60
  407.   set gSec to gSec - 1
  408.   if gSec < 0 then
  409.     set gMin to max(0, gMin - 1)
  410.     set gSec to 59
  411.   end if
  412.   if the number of chars in string(gSec) = 1 then
  413.     set cosSec to "0" & gSec
  414.   else
  415.     set cosSec to gSec
  416.   end if
  417.   if the number of chars in string(gMin) = 1 then
  418.     set cosMin to "0" & gMin
  419.   else
  420.     set cosMin to gMin
  421.   end if
  422.   set timetext to cosMin & ":" & cosSec
  423.   set aSpt to gFstRaceTime
  424.   repeat with X = 1 to the number of chars in timetext
  425.     set aChar to char X of timetext
  426.     set the memberNum of sprite aSpt to the number of member ("time " & aChar)
  427.     set aSpt to aSpt + 1
  428.   end repeat
  429. end
  430.  
  431. on doScore
  432.   put gScore into field "gScore"
  433.   set scoreText to string(gScore)
  434.   set aSpt to gFstRaceScore + 6
  435.   repeat with X = the number of chars in scoreText down to 1
  436.     set aChar to char X of scoreText
  437.     set the memberNum of sprite aSpt to the number of member ("score " & aChar)
  438.     set aSpt to aSpt - 1
  439.   end repeat
  440. end
  441.