home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / rockysbreakout / game.dcr / _gamecode_8__doggame.ls < prev    next >
Encoding:
Text File  |  2007-09-27  |  12.6 KB  |  429 lines

  1. property pStartPosition, pTrampHalf, pCollisionBuffer, pCollBuffer2, pBouncePower, pSplitPoint, pCurrentBoneI, pAmt, originalCamY, pVV, P1, P2, pRV, pBallObjToDelete, pPumpObjToDelete, pFinish, pMode, pFalling, pLastFalling, pControl, pTargetList, pBouncerList, pBLcnt, my, dogmesh, pTrampoline, pTdownModel, pTupModel, pTorigModel, pTrampTimer, pCamera, pTargetTimer, pBatModeTimer, pHelpCounter, pMouseMaxTop, pMouseMaxBottom, pStixMaxTop, pStixMaxBottom, pUDratio, pStixMaxLeft, pStixMaxRight, pMouseMaxLeft, pMouseMaxRight, pLRratio, pMaxH, pMinH, pMaxV, pMinV, pAnimSpeed, pMidPoint, pEndPoint
  2. global gWorld, game, gLevel
  3.  
  4. on new me, paramList
  5.   pMode = #launch
  6.   pAnimSpeed = 1.0
  7.   tTotalFrames = 60.0
  8.   tMid = tTotalFrames / 2.0
  9.   pMidPoint = tMid * 33.0
  10.   pEndPoint = tTotalFrames * 33.0
  11.   pCamera = paramList.cam
  12.   originalCamY = pCamera.worldPosition.y
  13.   t = vector(0, 0, 0)
  14.   pVV = t
  15.   P1 = t
  16.   P2 = t
  17.   pTrampHalf = 60
  18.   pCollisionBuffer = 20
  19.   pCollBuffer2 = pCollisionBuffer + 7
  20.   pBouncePower = 20
  21.   pSplitPoint = 30
  22.   pCurrentBoneI = 1
  23.   pAmt = 1
  24.   pRV = 0
  25.   pHelpCounter = 0
  26.   pTrampoline = gWorld.model("trampoline")
  27.   pTrampoline.addChild(gWorld.model("trampoline_frame1"))
  28.   pTrampoline.addChild(gWorld.model("trampoline_frame2"))
  29.   pTrampoline.addChild(gWorld.model("trampoline_frame3"))
  30.   pTrampoline.addChild(gWorld.model("tramp_frame"))
  31.   pTdownModel = pTrampoline.child[1]
  32.   pTdownModel.translate(0, 0, 10000)
  33.   pTupModel = pTrampoline.child[2]
  34.   pTupModel.translate(0, 0, 10000)
  35.   pTorigModel = pTrampoline.child[3]
  36.   pTrampoline.translate(20, 0, 0)
  37.   my = paramList.player
  38.   my.translate(0, 0, 4)
  39.   paramList.dog.worldPosition = my.worldPosition
  40.   paramList.dog.transform.scale = vector(2.5, 2.5, 2.5)
  41.   my.addChild(paramList.dog)
  42.   dogmesh = my.child[1]
  43.   my.child[1].bonesPlayer.playRate = pAnimSpeed
  44.   my.child[1].bonesPlayer.pause()
  45.   my.child[1].bonesPlayer.currentTime = 0
  46.   gWorld.model("dog_shadow").transform.position.y = -262.91190000000000282
  47.   gWorld.model("tramp_shadow").transform.position.y = -282.82139999999998281
  48.   gWorld.model("tramp_shadow").worldPosition.x = pTrampoline.worldPosition.x + 10
  49.   gWorld.shader("shadow_shader").blend = 60
  50.   gWorld.model("lingo_borderR").shader.blend = 0
  51.   pMaxH = integer(gWorld.model("lingo_borderR").worldPosition.x)
  52.   pMinH = integer(gWorld.model("lingo_borderL").worldPosition.x)
  53.   pMinV = 13
  54.   pMaxV = integer(gWorld.model("lingo_borderT").worldPosition.z)
  55.   my.worldPosition.x = pMinH
  56.   me.setupMouseControl()
  57.   pTargetList = []
  58.   repeat with x = 1 to gWorld.model.count
  59.     if gWorld.model[x].name contains "bone" then
  60.       pTargetList.add(gWorld.model[x])
  61.     end if
  62.   end repeat
  63.   pBouncerList = []
  64.   repeat with x = 1 to gWorld.model.count
  65.     if gWorld.model[x].name contains "bounce" then
  66.       pBouncerList.add(gWorld.model[x])
  67.     end if
  68.   end repeat
  69.   pBLcnt = pBouncerList.count
  70.   return me
  71. end
  72.  
  73. on stepit me
  74.   tOrigT = pCamera.transform.duplicate()
  75.   tC = pCamera
  76.   tCpos = tC.worldPosition
  77.   tTpos = pTrampoline.worldPosition
  78.   tMyPos = my.worldPosition
  79.   tDiff = tMyPos - tTpos
  80.   tDiffM = tDiff.magnitude * 0.5
  81.   tPointPoint = tMyPos - (tDiff * 0.40000000000000002)
  82.   if tPointPoint.z < 100 then
  83.     tPointPoint.z = 100
  84.   end if
  85.   tC.pointAt(tPointPoint, vector(0, 0, 1))
  86.   tFinal = originalCamY - tDiffM
  87.   ccY = tCpos.y
  88.   tPO = (tFinal - ccY) * 0.20000000000000001
  89.   if tMyPos.z > pSplitPoint then
  90.     pT = tMyPos
  91.     if pVV.z < 0 then
  92.       ttz = tPointPoint.z
  93.     else
  94.       ttz = tMyPos.z + 40
  95.     end if
  96.     pT = vector(tMyPos.x, 0, ttz)
  97.   else
  98.     ttz = tMyPos.z + 40
  99.     pT = vector(tTpos.x, 0, ttz)
  100.   end if
  101.   tP = 0.20000000000000001
  102.   TH = (pT.x - tCpos.x) * tP
  103.   tZ = (pT.z - tCpos.z) * 0.05
  104.   tC.translate(TH, tPO, tZ, #world)
  105.   tFinalT = tC.transform.duplicate()
  106.   tOrigT.interpolateTo(tFinalT, 20)
  107.   pCamera.transform.rotation = tOrigT.rotation
  108.   gWorld.model("dog_shadow").worldPosition.x = tMyPos.x
  109.   P1 = tMyPos
  110.   if pMode = #fly then
  111.     if pControl = #keyboard then
  112.       if keyPressed(123) then
  113.         pTrampoline.translate(-10, 0, 0)
  114.       else
  115.         if keyPressed(124) then
  116.           pTrampoline.translate(10, 0, 0)
  117.         end if
  118.       end if
  119.       tPos = pTrampoline.worldPosition
  120.     else
  121.       tMouseH = the mouseH
  122.       pStixH = (pLRratio * (tMouseH - pMouseMaxLeft)) + pStixMaxLeft
  123.       tP = 0.10000000000000001
  124.       pTrampoline.translate((pStixH - pTrampoline.worldPosition.x) * tP, 0, 0)
  125.       tPos = pTrampoline.worldPosition
  126.     end if
  127.     tBuffer = 20
  128.     if tPos.x < (pStixMaxLeft - tBuffer) then
  129.       pTrampoline.worldPosition.x = pStixMaxLeft - tBuffer
  130.       tPos.x = pStixMaxLeft
  131.     else
  132.       if tPos.x > (pStixMaxRight + tBuffer) then
  133.         pTrampoline.worldPosition.x = pStixMaxRight + tBuffer
  134.         tPos.x = pStixMaxRight
  135.       end if
  136.     end if
  137.     gWorld.model("tramp_shadow").worldPosition.x = tPos.x + 10
  138.     pGravity = vector(0, 0, -0.5)
  139.     pVV = pVV * 0.97999999999999998
  140.     if pVV.z < -3 then
  141.       pLastFalling = 1
  142.     else
  143.       pLastFalling = 0
  144.     end if
  145.     tMove = pGravity + pVV
  146.     if tMove.magnitude > 75 then
  147.       tMove = tMove.getNormalized() * 75
  148.     end if
  149.     my.translate(tMove, #world)
  150.     tX = my.worldPosition.x
  151.     if tX < pMinH then
  152.       my.worldPosition.x = pMinH
  153.       my.translate(abs(pVV.x), 0, 0)
  154.     else
  155.       if tX > pMaxH then
  156.         my.worldPosition.x = pMaxH
  157.         my.translate(-abs(pVV.x), 0, 0)
  158.       end if
  159.     end if
  160.     if my.worldPosition.z < pMinV then
  161.       my.worldPosition.z = pMinV
  162.       tDiff = pTrampoline.worldPosition.x - tX
  163.       put "tDiff" && tDiff
  164.       tDA = abs(tDiff)
  165.       if tDA < pTrampHalf then
  166.         my.translate(-tDiff, 0, 40)
  167.         sound(3).volume = 200
  168.         puppetSound(3, "bounce_pop")
  169.         me.makeSound()
  170.         my.child[1].bonesPlayer.play("dog", 0, 0, pMidPoint, pAnimSpeed)
  171.         pRV = tDiff
  172.         if tDA < ((pTrampHalf / 2) + 10) then
  173.           me.animT(#down)
  174.           pTrampTimer = 10
  175.         end if
  176.       else
  177.         me.killDog()
  178.       end if
  179.     else
  180.       if my.worldPosition.z > pMaxV then
  181.         my.worldPosition.z = pMaxV
  182.       end if
  183.     end if
  184.     dogmesh.rotate(0, pRV, 0)
  185.     pRV = pRV * 0.97999999999999998
  186.     P2 = my.worldPosition
  187.     pVV = P2 - P1
  188.     if (pVV.z < -3) and (pLastFalling = 0) then
  189.       sound(4).volume = 75
  190.       puppetSound(4, "fall_whistle")
  191.       my.child[1].bonesPlayer.play("dog", 0, pMidPoint, pEndPoint, pAnimSpeed)
  192.     end if
  193.     if pTrampTimer > 0 then
  194.       pTrampTimer = pTrampTimer - 1
  195.       if pTrampTimer = 6 then
  196.         me.animT(#normal)
  197.       else
  198.         if pTrampTimer = 5 then
  199.           me.animT(#up)
  200.         else
  201.           if pTrampTimer = 2 then
  202.             me.animT(#normal)
  203.           end if
  204.         end if
  205.       end if
  206.     end if
  207.   else
  208.     if pMode = #launch then
  209.       pHelpCounter = pHelpCounter + 1
  210.       if pHelpCounter > 30 then
  211.         game.HUD.showInstruction(#on)
  212.       end if
  213.       if the mouseDown or keyPressed(" ") then
  214.         my.translate(6, 0, 30)
  215.         pMode = #fly
  216.         sound(3).volume = 255
  217.         puppetSound(3, "bounce_pop")
  218.         my.child[1].bonesPlayer.play("dog", 0, 0, pMidPoint, pAnimSpeed)
  219.         me.makeSound()
  220.         if pHelpCounter > 30 then
  221.           game.HUD.showInstruction(#off)
  222.         end if
  223.         if keyPressed(" ") then
  224.           pControl = #keyboard
  225.         end if
  226.       end if
  227.       P2 = my.worldPosition
  228.       pVV = P2 - P1
  229.       pRV = 4
  230.     else
  231.       if pMode = #crash then
  232.         pFinish = pFinish + 1
  233.         if pFinish = 60 then
  234.           puppetSound(2, 0)
  235.           puppetSound(3, 0)
  236.           puppetSound(4, 0)
  237.           game.stop()
  238.           member("score_final_text").text = member("score_text").text
  239.           go("finish")
  240.           cursor(0)
  241.         end if
  242.       else
  243.         if pMode = #finish then
  244.           pFinish = pFinish + 1
  245.           my.child[1].rotate(0, 6, 0)
  246.           if pFinish = 2 then
  247.             sound(1).volume = 255
  248.             puppetSound(1, "clap")
  249.           else
  250.             if pFinish = 120 then
  251.               game.stop()
  252.               member("score_final_text").text = member("score_text").text
  253.               gLevel = gLevel + 1
  254.               gLevel = min(gLevel, 5)
  255.               go("win")
  256.               cursor(0)
  257.             end if
  258.           end if
  259.           if pFinish = 30 then
  260.             sound(2).volume = 220
  261.             puppetSound(2, "dog4")
  262.           else
  263.             if pFinish = 40 then
  264.               puppetSound(2, "dog4")
  265.             else
  266.               if pFinish = 70 then
  267.                 puppetSound(2, "dog4")
  268.               end if
  269.             end if
  270.           end if
  271.           if pFinish = 23 then
  272.             game.HUD.popFirework()
  273.           else
  274.             if pFinish = 34 then
  275.               game.HUD.popFirework()
  276.             else
  277.               if pFinish = 43 then
  278.                 game.HUD.popFirework()
  279.               else
  280.                 if pFinish = 64 then
  281.                   game.HUD.popFirework()
  282.                 else
  283.                   if pFinish = 80 then
  284.                     game.HUD.popFirework()
  285.                   end if
  286.                 end if
  287.               end if
  288.             end if
  289.           end if
  290.         end if
  291.       end if
  292.     end if
  293.   end if
  294.   tMyx = my.worldPosition.x
  295.   tMyz = my.worldPosition.z
  296.   pBoneMaxI = pTargetList.count
  297.   if pBoneMaxI > 0 then
  298.     pCurrentBoneI = pCurrentBoneI + 1
  299.     if pCurrentBoneI > pBoneMaxI then
  300.       pCurrentBoneI = 1
  301.     end if
  302.     pTargetList[pCurrentBoneI].rotate(0, 5, 0)
  303.     repeat with x = 1 to pBoneMaxI
  304.       tm = pTargetList[x]
  305.       tm.rotate(0, 5, 0)
  306.       if abs(tMyx - tm.worldPosition.x) < pCollisionBuffer then
  307.         if abs(tMyz - tm.worldPosition.z) < pCollisionBuffer then
  308.           me.collectBone()
  309.           pTargetList.deleteOne(tm)
  310.           tm.removeFromWorld()
  311.           exit repeat
  312.         end if
  313.       end if
  314.     end repeat
  315.     if gLevel < 4 then
  316.       repeat with x = 1 to pBLcnt
  317.         tm = pBouncerList[x]
  318.         tm.rotate(3, -5, -0.5)
  319.         if abs(tMyx - tm.worldPosition.x) < pCollBuffer2 then
  320.           if abs(tMyz - tm.worldPosition.z) < pCollBuffer2 then
  321.             tVec = vector(tMyx - tm.worldPosition.x, 0, tMyz - tm.worldPosition.z)
  322.             tVec = tVec.getNormalized() * 10
  323.             put tVec
  324.             my.translate(tVec)
  325.             sound(4).volume = 255
  326.             puppetSound(4, "bumper")
  327.             P2 = my.worldPosition
  328.             pVV = P2 - P1
  329.             pRV = pRV + 1
  330.             exit repeat
  331.           end if
  332.         end if
  333.       end repeat
  334.     else
  335.       if pAmt < 10 then
  336.         pAmt = pAmt + 0.5
  337.       else
  338.         pAmt = -pAmt
  339.       end if
  340.       repeat with x = 1 to pBLcnt
  341.         tm = pBouncerList[x]
  342.         tm.rotate(0, 0, 5)
  343.         tm.translate(pAmt, 0, 0)
  344.         if abs(tMyx - tm.worldPosition.x) < pCollBuffer2 then
  345.           if abs(tMyz - tm.worldPosition.z) < pCollBuffer2 then
  346.             tVec = vector(tMyx - tm.worldPosition.x, 0, tMyz - tm.worldPosition.z)
  347.             tVec = tVec.getNormalized() * 10
  348.             put tVec
  349.             my.translate(tVec)
  350.             P2 = my.worldPosition
  351.             pVV = P2 - P1
  352.             pRV = pRV + 1
  353.             exit repeat
  354.           end if
  355.         end if
  356.       end repeat
  357.     end if
  358.   else
  359.     pMode = #finish
  360.   end if
  361.   if keyPressed("s") then
  362.     if the runMode contains "author" then
  363.       pMode = #finish
  364.     end if
  365.   end if
  366. end
  367.  
  368. on animT me, whichway
  369.   tUp = 0
  370.   case whichway of
  371.     #up:
  372.       pTdownModel.transform.position = vector(0, 0, 10000)
  373.       pTupModel.transform.position = vector(0, 0, tUp)
  374.       pTorigModel.transform.position = vector(0, 0, 10000)
  375.     #down:
  376.       pTdownModel.transform.position = vector(0, 0, tUp)
  377.       pTupModel.transform.position = vector(0, 0, 10000)
  378.       pTorigModel.transform.position = vector(0, 0, 10000)
  379.     #normal:
  380.       pTdownModel.transform.position = vector(0, 0, 10000)
  381.       pTupModel.transform.position = vector(0, 0, 10000)
  382.       pTorigModel.transform.position = vector(0, 0, tUp)
  383.   end case
  384. end
  385.  
  386. on makeSound me
  387.   tn = random(6)
  388.   tS = "dog" & tn
  389.   sound(2).volume = random(200) + 55
  390.   puppetSound(2, tS)
  391. end
  392.  
  393. on killDog me
  394.   if pMode = #fly then
  395.     puppetSound(3, 0)
  396.     sound(4).volume = 255
  397.     puppetSound(4, "dog6")
  398.   end if
  399.   pMode = #crash
  400.   pVV = vector(0, 0, 0)
  401.   pRV = 0
  402.   dogmesh.transform.rotation = vector(0, 0, 0)
  403.   my.child[1].bonesPlayer.pause()
  404.   my.child[1].bonesPlayer.currentTime = 0
  405.   my.worldPosition.z = 15
  406. end
  407.  
  408. on collectBone me
  409.   sound(3).volume = random(20) + 50
  410.   puppetSound(3, "witchlaugh")
  411.   game.HUD.showscore(my.worldPosition, 500)
  412.   tn = random(6)
  413.   tS = "dog" & tn
  414.   sound(2).volume = random(200) + 55
  415.   puppetSound(2, tS)
  416. end
  417.  
  418. on setupMouseControl me
  419.   pStixMaxLeft = pMinH + pTrampHalf
  420.   pStixMaxRight = pMaxH - pTrampHalf
  421.   pMouseMaxLeft = 0.0
  422.   pMouseMaxRight = 380.0
  423.   x2 = pMouseMaxRight
  424.   x1 = pMouseMaxLeft
  425.   y2 = pStixMaxRight
  426.   y1 = pStixMaxLeft
  427.   pLRratio = (y1 - y2) / (x1 - x2)
  428. end
  429.