home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / rollon / rollon.dcr / 00003_BallBehaviour.ls < prev    next >
Encoding:
Text File  |  2004-09-09  |  18.8 KB  |  659 lines

  1. property w, hk, ball, ballRB, course, courseRB, movingBits, movingBitsRB, sky, arrow, snowflake, bitsMember, courseMember, styleMember, startNull, finishNull, upkey, downkey, leftkey, rightkey, spacekey, ballStopCheck, arrowY, arrowYmax, blackFade, pShadow, dirList, pTeleA, pTeleB, pTeleAll, pTelePos, pSpinner, pStyle, pProtected, pStartTime, pBallPos, pSpeed, pSpeedVector, pheight, pGroundPos, pGroundNorm, pGroundSurf, pHorizLevel, pVertLevel, pLevelMax, pPowerFactor, pInertia, pBGRots, pPacks, pBgT, pTimeStr, pPacksCollected, _DEBUG, prevCamMode
  2. global playMode, holeNum, styleNum, cam, camMode, camStart, camBuffer, gScore, gLives, gNewLevel, gMode
  3.  
  4. on beginSprite me
  5.   _DEBUG = 0
  6.   gNewLevel = 0
  7.   member(2).resetWorld()
  8.   bitsMember = member(29)
  9.   bitsMember.resetWorld()
  10.   styleMember = member(26 + (styleNum * 4))
  11.   styleMember.resetWorld()
  12.   if holeNum > 21 then
  13.     courseMember = 36 + holeNum
  14.   else
  15.     courseMember = 29 + styleNum + holeNum
  16.   end if
  17.   sprite(2).memberNum = courseMember
  18.   w = member(courseMember)
  19.   w.resetWorld()
  20.   w.directionalPreset = #bottomLeft
  21.   hk = member(11)
  22.   hk.Initialize(w, 1, 0.025)
  23.   put "Got to camera mode with holeNum " & holeNum && "styleNum  " & styleNum
  24.   camMode = camStart[holeNum]
  25.   styles = ["Garden", "Stately", "Hanger", "Sushi", "Sea", "Modern", "Mountains"]
  26.   pStyle = styles[styleNum]
  27.   put "STYLE = " & pStyle
  28.   createObjects()
  29.   initVars()
  30. end
  31.  
  32. on createObjects me
  33.   hk.gravity = vector(0, -200, 0)
  34.   startNull = w.model("start")
  35.   finishNull = w.model("finish")
  36.   createBall()
  37.   pShadow = w.cloneModelFromCastmember("BallShadow", "BallShadow", bitsMember)
  38.   pShadow.scale(1.5, 1.5, 1.5)
  39.   if holeNum < 10 then
  40.     mn = "Level0" & holeNum
  41.   else
  42.     mn = "Level" & holeNum
  43.   end if
  44.   course = w.model(mn)
  45.   id = (holeNum mod 8) + 1
  46.   course.addModifier(#meshDeform)
  47.   courseRB = hk.makeFixedRigidBody(course.name, 0)
  48.   courseRB.friction = 0.80000000000000004
  49.   pPacks = []
  50.   m = w.cloneModelFromCastmember("Box1", "BoxRK", bitsMember)
  51.   w.model("BoxRK").addChild(m, #preserveParent)
  52.   pPacks.add(m)
  53.   m = w.cloneModelFromCastmember("Box2", "BoxFrosties", bitsMember)
  54.   w.model("BoxFrosties").addChild(m, #preserveParent)
  55.   pPacks.add(m)
  56.   m = w.cloneModelFromCastmember("Box3", "BoxLoops", bitsMember)
  57.   w.model("BoxLoops").addChild(m, #preserveParent)
  58.   pPacks.add(m)
  59.   m = w.cloneModelFromCastmember("Box4", "BoxRicicles", bitsMember)
  60.   w.model("BoxRicicles").addChild(m, #preserveParent)
  61.   pPacks.add(m)
  62.   m = w.cloneModelFromCastmember("Box5", "BoxCoco", bitsMember)
  63.   w.model("BoxCoco").addChild(m, #preserveParent)
  64.   pPacks.add(m)
  65.   m = w.cloneModelFromCastmember("Box6", "BoxCornflakes", bitsMember)
  66.   w.model("BoxCornflakes").addChild(m, #preserveParent)
  67.   pPacks.add(m)
  68.   arrow = w.cloneModelFromCastmember("Arrow", "Arrow", bitsMember)
  69.   arrow.transform = finishNull.getWorldTransform()
  70.   arrow.translate(0, 500, 0)
  71.   sky = w.cloneModelFromCastmember("SkyBoxBG", "SkyBox" & pStyle, styleMember)
  72.   sky.scale(50.0)
  73.   sky.translate(0, -10000, 0)
  74.   pBgT = sky.getWorldTransform()
  75.   if pStyle = "Snowy" then
  76.     snowflake = []
  77.     snowflake.add(w.cloneModelFromCastmember("SnowFlake", "SnowFlake", styleMember))
  78.     tn = transform()
  79.     tn.position = course.worldPosition
  80.     snowflake[1].transform = tn
  81.     cm = camStart[holeNum]
  82.     if cm <> 1 then
  83.       repeat with i = cm to 4
  84.         snowflake[1].rotate(course.worldPosition, vector(0, 1, 0), -90, #world)
  85.       end repeat
  86.     end if
  87.     repeat with i = 2 to 256
  88.       snowflake.add(w.model("SnowFlake").clone("SnowFlake" & i))
  89.     end repeat
  90.     num = 1
  91.     repeat with i = 1 to 8
  92.       repeat with j = 1 to 8
  93.         repeat with k = 1 to 4
  94.           ran = 160 - random(320)
  95.           xm = ((j * 200) - 600) * i
  96.           ym = ((k * 200) - 200) * i
  97.           zm = (i * -500) + 1600
  98.           snowflake[num].translate(xm + ran, ym + ran, zm + ran)
  99.           num = num + 1
  100.         end repeat
  101.       end repeat
  102.     end repeat
  103.     w.texture("SnowFlake").renderFormat = #rgba4444
  104.   end if
  105.   bf = w.newTexture("BlackFade", #fromCastMember, member("black"))
  106.   w.camera[1].addOverlay(bf, point(0, 0), 0)
  107.   w.camera[1].overlay[1].scale = 600
  108.   w.camera[1].overlay[1].blend = 100
  109.   blackFade = 100
  110.   pTeleA = []
  111.   pTeleB = []
  112.   pTeleAll = []
  113.   pSpinner = []
  114.   c = w.model.count
  115.   repeat with i = 1 to c
  116.     m = w.model[i]
  117.     if chars(m.name, 1, 7) = "Spinner" then
  118.       if pSpinner.count = 0 then
  119.         pSpinner.add(w.cloneModelFromCastmember("Spinner0", "Spinner", bitsMember))
  120.       else
  121.         pSpinner.add(pSpinner[1].clone("Spinner" & pSpinner.count))
  122.       end if
  123.       m.addChild(pSpinner[pSpinner.count], #preserveParent)
  124.       next repeat
  125.     end if
  126.     if chars(m.name, 1, 8) = "Teleport" then
  127.       if pTeleAll.count = 0 then
  128.         tp = w.cloneModelFromCastmember("Teleport0", "Teleport", bitsMember)
  129.       else
  130.         tp = w.model("Teleport0").clone("Teleport" & pTeleAll.count)
  131.       end if
  132.       pTeleAll.add(m)
  133.       m.addChild(tp, #preserveParent)
  134.       if chars(m.name, 9, 9) = "G" then
  135.         pTeleA.add(m)
  136.         next repeat
  137.       end if
  138.       pTeleB.add(m)
  139.     end if
  140.   end repeat
  141.   repeat with i = 1 to w.shader.count
  142.     s = w.shader[i]
  143.     sn = chars(s.name, 1, 3)
  144.     if (sn = "Sky") and (s.texture[1] <> VOID) then
  145.       s.diffuse = rgb(255, 255, 255)
  146.       s.texture[1].renderFormat = #rgba8880
  147.       s.textureRepeatList[1] = 0
  148.     end if
  149.   end repeat
  150.   w.shader("ShadowShader").blend = 50
  151.   w.texture("ShadowCol").renderFormat = #rgba4444
  152.   if pStyle = "Space" then
  153.     w.shader("CubeShader").blend = 23
  154.   end if
  155.   if pTeleAll.count > 0 then
  156.     w.shader("TeleportShader").texture[1].renderFormat = #rgba4444
  157.   end if
  158.   if (pSpinner.count > 0) and (pStyle = "Snowy") then
  159.     w.shader("TreeTrunkShader").ambient = rgb(86, 47, 12)
  160.     w.texture("Tree").renderFormat = #rgba4444
  161.   end if
  162.   t = w.newTexture("GlowEdges", #fromCastMember, member("Glow"))
  163.   w.shader("EdgesShader").diffuse = color(255, 255, 255)
  164.   w.shader("EdgesShader").emissive = color(255, 255, 255)
  165.   w.shader("EdgesShader").textureList[1] = t
  166.   w.shader("EdgesShader").textureModeList[1] = #wrapSpherical
  167. end
  168.  
  169. on createBall
  170.   ball = w.cloneModelFromCastmember("Ball", "Ball", bitsMember)
  171.   ball.addModifier(#meshDeform)
  172.   ballRB = hk.makeMovableRigidBody(ball.name, 1, 1, #sphere)
  173.   ballRB.restitution = 2
  174.   ballRB.friction = 0.80000000000000004
  175.   tn = startNull.getWorldTransform()
  176.   ballRB.linearVelocity = vector(0, 0, 0)
  177.   ballRB.angularVelocity = vector(0, 0, 0)
  178.   ballRB.attemptMoveTo(tn.position, [vector(0, 1, 0), 0])
  179. end
  180.  
  181. on initVars
  182.   ballStopCheck = 10
  183.   arrowYmax = 20
  184.   arrowY = -arrowYmax
  185.   xa = course.transform.xAxis
  186.   za = course.transform.zAxis
  187.   dirList = [-za, za, -xa, xa, -xa, xa, za, -za, za, -za, xa, -xa, xa, -xa, -za, za]
  188.   bgRot = 0.29999999999999999
  189.   pBGRots = [vector(bgRot, 0, 0), vector(0, 0, -bgRot), vector(-bgRot, 0, 0), vector(0, 0, -bgRot), vector(0, 0, -bgRot), vector(-bgRot, 0, 0), vector(0, 0, bgRot), vector(bgRot, 0, 0)]
  190.   pHorizLevel = 0
  191.   pVertLevel = 0
  192.   pLevelMax = 200
  193.   pInertia = 2
  194.   pPowerFactor = 10
  195.   playMode = "START"
  196.   if gMode.demo then
  197.     n = gMode.id
  198.   else
  199.     n = holeNum
  200.   end if
  201.   info = "COURSE " & n
  202.   setVariable(sprite(1), "info", info)
  203.   sprite(1).setVariable("levelNum", string(n))
  204.   sprite(1).packs = 0
  205.   pPacksCollected = 0
  206.   pProtected = [#mode: 0, #startTime: 0]
  207.   prevCamMode = camMode
  208. end
  209.  
  210. on setTime
  211.   return 
  212.   timeGone = the timer - pStartTime
  213.   ticksToGo = (2 * 60 * 60) - timeGone
  214.   if ticksToGo < 0 then
  215.     sprite(1).setVariable("info", "Whoops! You ran out of time on level " & holeNum)
  216.     sprite(1).setVariable("scoreinfo", "You scored " & gScore)
  217.     moveFlash("endgame")
  218.     playMode = "ENDGAME"
  219.   else
  220.     ntSecs = integer(ticksToGo / 60.0)
  221.     ntMins = integer(ntSecs / 60.0)
  222.     ntSecs = integer(ntSecs - (ntMins * 60.0))
  223.     if ntSecs < 0 then
  224.       ntMins = ntMins - 1
  225.       ntSecs = ntSecs + 60
  226.     end if
  227.     if ntMins < 10.0 then
  228.       ntMins = "0" & string(ntMins)
  229.     end if
  230.     if ntSecs < 10.0 then
  231.       ntSecs = "0" & string(ntSecs)
  232.     end if
  233.     pTimeStr = string(ntMins) & ":" & string(ntSecs)
  234.     setVariable(sprite(1), "time", pTimeStr)
  235.   end if
  236. end
  237.  
  238. on enterFrame
  239.   spinStuff()
  240.   CP = cam.worldPosition
  241.   CP.y = arrow.transform.position.y
  242.   arrow.pointAt(CP, vector(0, 1, 0))
  243.   arrowY = arrowY + 1
  244.   if arrowY >= arrowYmax then
  245.     arrowY = -arrowYmax
  246.   end if
  247.   if arrowY >= 0 then
  248.     arrow.translate(0, 6, 0)
  249.   else
  250.     arrow.translate(0, -6, 0)
  251.   end if
  252.   skyRotV = 0
  253.   skyRotH = 0
  254.   if playMode = "ACTIVE" then
  255.     checkKeys()
  256.     c = (camMode - 1) * 4
  257.     moved = 0
  258.     if upkey then
  259.       if pVertLevel < pLevelMax then
  260.         skyRotV = 1
  261.         pVertLevel = pVertLevel + pInertia
  262.       end if
  263.       p = ((pLevelMax * 0.5) + pVertLevel) / pPowerFactor
  264.       hitV = dirList[c + 1] * p
  265.       moved = 1
  266.     else
  267.       if downkey then
  268.         if pVertLevel > -pLevelMax then
  269.           skyRotV = -1
  270.           pVertLevel = pVertLevel - pInertia
  271.         end if
  272.         p = ((pLevelMax * 0.5) - pVertLevel) / pPowerFactor
  273.         hitV = dirList[c + 2] * p
  274.         moved = 1
  275.       else
  276.         if leftkey then
  277.           if pHorizLevel < pLevelMax then
  278.             skyRotH = 1
  279.             pHorizLevel = pHorizLevel + pInertia
  280.           end if
  281.           p = ((pLevelMax * 0.5) + pHorizLevel) / pPowerFactor
  282.           hitV = dirList[c + 3] * p
  283.           moved = 1
  284.         else
  285.           if rightkey then
  286.             if pHorizLevel > -pLevelMax then
  287.               skyRotH = -1
  288.               pHorizLevel = pHorizLevel - pInertia
  289.             end if
  290.             p = ((pLevelMax * 0.5) - pHorizLevel) / pPowerFactor
  291.             hitV = dirList[c + 4] * p
  292.             moved = 1
  293.           end if
  294.         end if
  295.       end if
  296.     end if
  297.     if moved then
  298.       ballRB.applyImpulse(hitV)
  299.     end if
  300.     if skyRotV <> 0 then
  301.       sky.rotate(pBGRots[camMode] * skyRotV)
  302.     else
  303.       if skyRotH <> 0 then
  304.         sky.rotate(pBGRots[camMode + 4] * skyRotH)
  305.       end if
  306.     end if
  307.     setTime()
  308.   else
  309.     if playMode = "TELE" then
  310.       if pheight > 300 then
  311.         ballRB.linearVelocity = vector(0, 0, 0)
  312.         ballRB.angularVelocity = vector(0, 0, 0)
  313.         ballRB.attemptMoveTo(pTelePos.position, [vector(0, 1, 0), 0])
  314.         playMode = "ACTIVE"
  315.       end if
  316.       setTime()
  317.     end if
  318.   end if
  319.   if playMode = "ENDGAME" then
  320.     go("endgame")
  321.     return 
  322.   end if
  323.   getInfo()
  324.   if (pSpeed < 70) and (playMode = "ACTIVE") then
  325.     inHole = checkHole()
  326.     if inHole then
  327.       endHole()
  328.       ballRB.active = 0
  329.       if holeNum = 12 then
  330.         movingBitsRB[1].active = 0
  331.         movingBitsRB[2].active = 0
  332.       end if
  333.     end if
  334.   end if
  335.   p = ball.worldPosition
  336.   dist = (p.x * p.x) + (p.y * p.y) + (p.z * p.z)
  337.   if dist > 100000000 then
  338.     gLives = gLives - 1
  339.     if gLives = 0 then
  340.       if gMode.demo then
  341.         n = gMode.id
  342.       else
  343.         n = holeNum
  344.       end if
  345.       sprite(1).setVariable("info", "Whoops! You ran out of lives on level " & n)
  346.       sprite(1).setVariable("scoreinfo", "You scored " & gScore)
  347.       moveFlash("endgame")
  348.       playMode = "ENDGAME"
  349.     else
  350.       tn = startNull.getWorldTransform()
  351.       put tn.position
  352.       ballRB.linearVelocity = vector(0, 0, 0)
  353.       ballRB.angularVelocity = vector(0, 0, 0)
  354.       Res = ballRB.attemptMoveTo(tn.position, [vector(0, 1, 0), 0])
  355.       if not Res then
  356.         ballRB.position = tn.position
  357.       end if
  358.       sprite(1).setVariable("lives", string(gLives))
  359.       sky.transform = pBgT
  360.       pHorizLevel = 0
  361.       pVertLevel = 0
  362.     end if
  363.   end if
  364.   if (playMode = "START") or (playMode = "HOLED") then
  365.     fadeHole()
  366.   end if
  367.   hk.step()
  368.   if playMode = "ACTIVE" then
  369.     checkTeles()
  370.     checkSpinners()
  371.     checkPacks()
  372.   end if
  373.   setShadow()
  374.   if pStyle = "Snowy" then
  375.     moveSnow()
  376.   end if
  377.   if keyPressed("q") then
  378.   end if
  379. end
  380.  
  381. on checkPacks
  382.   pos = ball.worldPosition
  383.   repeat with i = 1 to pPacks.count
  384.     m = pPacks[i]
  385.     if m.visibility = #front then
  386.       v = pos - m.worldPosition
  387.       dist = (v.x * v.x) + (v.y * v.y) + (v.z * v.z)
  388.       if dist < 10000 then
  389.         boxname = m.parent.name
  390.         if boxname = "BoxCornflakes" then
  391.           sprite(1).setVariable("pack1", "found")
  392.           gLives = gLives + 2
  393.           sprite(1).lives = gLives
  394.           m.visibility = #none
  395.           soundFX("munch", 3, 255)
  396.           next repeat
  397.         end if
  398.         if (boxname = "BoxFrosties") and (pProtected.mode = 0) then
  399.           sprite(1).setVariable("pack2", "found")
  400.           pProtected = [#mode: 1, #startTime: _system.milliSeconds, #shield: m]
  401.           m.scale(0.59999999999999998)
  402.           soundFX("munch", 3, 255)
  403.           next repeat
  404.         end if
  405.         if boxname = "BoxCoco" then
  406.           gLives = gLives + 1
  407.           sprite(1).lives = gLives
  408.           sprite(1).setVariable("pack3", "found")
  409.           m.visibility = #none
  410.           soundFX("munch", 3, 255)
  411.           next repeat
  412.         end if
  413.         if boxname = "BoxRK" then
  414.           pPacksCollected = pPacksCollected + 3
  415.           packScore = pPacksCollected * 350 * holeNum
  416.           sprite(1).setVariable("packs", string(packScore))
  417.           sprite(1).setVariable("pack4", "found")
  418.           m.visibility = #none
  419.           soundFX("munch", 3, 255)
  420.           next repeat
  421.         end if
  422.         if boxname = "BoxLoops" then
  423.           pPacksCollected = pPacksCollected + 1
  424.           packScore = pPacksCollected * 350 * holeNum
  425.           sprite(1).setVariable("packs", string(packScore))
  426.           sprite(1).setVariable("pack5", "found")
  427.           m.visibility = #none
  428.           soundFX("munch", 3, 255)
  429.           next repeat
  430.         end if
  431.         if boxname = "BoxRicicles" then
  432.           pPacksCollected = pPacksCollected + 2
  433.           packScore = pPacksCollected * 350 * holeNum
  434.           sprite(1).setVariable("packs", string(packScore))
  435.           sprite(1).setVariable("pack6", "found")
  436.           m.visibility = #none
  437.           soundFX("munch", 3, 255)
  438.         end if
  439.       end if
  440.     end if
  441.   end repeat
  442. end
  443.  
  444. on moveSnow
  445.   rate = float(the timer) / 500.0
  446.   repeat with i = 1 to 256
  447.     row = integer(i / 20) * rate
  448.     col = i mod 20 * rate
  449.     xm = sin(row) * cos(col) * 3
  450.     zm = sin(col) * cos(row) * 2
  451.     snowflake[i].translate(xm, -3, zm)
  452.     if snowflake[i].transform.position.y < -100 then
  453.       snowflake[i].translate(0, 700, 0)
  454.     end if
  455.     if camMode <> prevCamMode then
  456.       snowflake[i].rotate(course.worldPosition, vector(0, 1, 0), 90, #world)
  457.     end if
  458.   end repeat
  459.   prevCamMode = camMode
  460. end
  461.  
  462. on setShadow
  463.   if pheight > 0 then
  464.     pShadow.worldPosition = ball.worldPosition
  465.     pShadow.translate(0, -pheight + 20, 0)
  466.   else
  467.     pShadow.transform.position = vector(0, -100000, 0)
  468.   end if
  469. end
  470.  
  471. on getInfo
  472.   pSpeedVector = ballRB.linearVelocity
  473.   pSpeed = pSpeedVector.magnitude
  474.   pBallPos = ball.worldPosition
  475.   pheight = 0
  476.   wpoint = pBallPos
  477.   wdown = vector(0, -1, 0)
  478.   opts = [#maxDistance: 80, #levelOfDetail: #detailed, #modelList: [course]]
  479.   idetails = w.modelsUnderRay(wpoint, wdown, opts)
  480.   if idetails.count > 0 then
  481.     repeat with i = 1 to idetails.count
  482.       mn = idetails[i].model.name
  483.       pheight = idetails[i].distance
  484.       pGroundPos = idetails[i].isectPosition
  485.       pGroundNorm = idetails[i].isectNormal
  486.       pGroundSurf = idetails[i].meshID
  487.       exit repeat
  488.     end repeat
  489.   end if
  490. end
  491.  
  492. on endHole
  493.   timeScore = 7200 - (the timer - pStartTime)
  494.   timeScore = integer(timeScore * 0.5)
  495.   if timeScore < 0 then
  496.     timeScore = 10
  497.   end if
  498.   if gMode.demo then
  499.     n = gMode.id
  500.   else
  501.     n = holeNum
  502.   end if
  503.   timeScore = timeScore * holeNum
  504.   sprite(1).setVariable("timeinfo", "Time remaining: " & pTimeStr & " = " & timeScore & " points")
  505.   packScore = pPacksCollected * 350 * holeNum
  506.   sprite(1).setVariable("packinfo", "Bonuses collected: " & pPacksCollected & " = " & packScore & " points")
  507.   levelScore = timeScore + packScore
  508.   gScore = gScore + levelScore
  509.   put "endHole gScore = " & gScore
  510.   sprite(1).setVariable("scoreinfo", "Level " & n & " Score = " & levelScore & RETURN & "  Total Score = " & gScore)
  511.   soundFX("ground", 2, 255)
  512.   playMode = "HOLED"
  513. end
  514.  
  515. on checkHole
  516.   dist = ball.worldPosition.distanceTo(finishNull.worldPosition)
  517.   if dist < 150 then
  518.     ballStopCheck = ballStopCheck - 1
  519.   else
  520.     ballStopCheck = 10
  521.   end if
  522.   if ballStopCheck <= 0 then
  523.     return 1
  524.   else
  525.     return 0
  526.   end if
  527. end
  528.  
  529. on fadeHole
  530.   if playMode = "HOLED" then
  531.     blackFade = blackFade + 1
  532.     if blackFade = 100 then
  533.       playMode = "FINISH"
  534.       go(the frame + 1)
  535.     end if
  536.   else
  537.     blackFade = blackFade - 1
  538.     if blackFade = 0 then
  539.       pStartTime = the timer
  540.       playMode = "ACTIVE"
  541.     end if
  542.   end if
  543.   w.camera[1].overlay[1].blend = blackFade
  544. end
  545.  
  546. on spinStuff
  547.   repeat with i = 1 to pSpinner.count
  548.     pSpinner[i].rotate(0, -20, 0)
  549.   end repeat
  550.   repeat with i = 1 to pTeleAll.count
  551.     pTeleAll[i].rotate(0, 40, 0)
  552.   end repeat
  553.   w.shader("EdgesShader").textureTransformList[1].rotate(0, 0, 0.20000000000000001)
  554. end
  555.  
  556. on checkTeles
  557.   if pProtected.mode then
  558.     return 
  559.   end if
  560.   repeat with i = 1 to pTeleB.count
  561.     v = pBallPos - pTeleB[i].worldPosition
  562.     dist = (v.x * v.x) + (v.y * v.y) + (v.z * v.z)
  563.     if dist < 20000 then
  564.       pTelePos = pTeleA[1].getWorldTransform()
  565.       pTelePos.position.y = pTelePos.position.y + 300
  566.       ballRB.linearVelocity = ballRB.linearVelocity * 0.20000000000000001
  567.       ballRB.applyImpulse(vector(0, 400, 0))
  568.       playMode = "TELE"
  569.     end if
  570.   end repeat
  571. end
  572.  
  573. on checkSpinners
  574.   if pProtected.mode then
  575.     tm = _system.milliSeconds - pProtected.startTime
  576.     pProtected.shield.worldPosition = ball.worldPosition
  577.     pProtected.shield.translate(0, 100, 0)
  578.     if tm < 30000 then
  579.       return 
  580.     end if
  581.     pProtected.shield.visibility = #none
  582.     pProtected.mode = 0
  583.   end if
  584.   repeat with i = 1 to pSpinner.count
  585.     v = pBallPos - pSpinner[i].worldPosition
  586.     dist = (v.x * v.x) + (v.y * v.y) + (v.z * v.z)
  587.     if dist < 30000 then
  588.       temp = v.x
  589.       v.x = -v.z
  590.       v.z = temp
  591.       v.y = 0
  592.       vm = (301 - dist) / 300
  593.       v = v * vm
  594.       ballRB.applyImpulse(v)
  595.     end if
  596.   end repeat
  597. end
  598.  
  599. on checkKeys
  600.   leftkey = 0
  601.   rightkey = 0
  602.   downkey = 0
  603.   upkey = 0
  604.   spacekey = 0
  605.   if keyPressed(123) then
  606.     leftkey = 1
  607.   end if
  608.   if keyPressed(124) then
  609.     rightkey = 1
  610.   end if
  611.   if keyPressed(125) then
  612.     downkey = 1
  613.   end if
  614.   if keyPressed(126) then
  615.     upkey = 1
  616.   end if
  617.   if keyPressed(" ") then
  618.     spacekey = 1
  619.   end if
  620.   if _DEBUG then
  621.     if keyPressed("s") or keyPressed("S") then
  622.       if soundBusy(1) then
  623.         sound(1).stop()
  624.       else
  625.         sound(1).play(member("music"))
  626.       end if
  627.     end if
  628.     if keyPressed("1") then
  629.       gNewLevel = 1
  630.       playMode = "HOLED"
  631.     else
  632.       if keyPressed("2") then
  633.         gNewLevel = 4
  634.         playMode = "HOLED"
  635.       else
  636.         if keyPressed("3") then
  637.           gNewLevel = 7
  638.           playMode = "HOLED"
  639.         else
  640.           if keyPressed("4") then
  641.             gNewLevel = 10
  642.             playMode = "HOLED"
  643.           else
  644.             if keyPressed("5") then
  645.               gNewLevel = 13
  646.               playMode = "HOLED"
  647.             end if
  648.           end if
  649.         end if
  650.       end if
  651.     end if
  652.   end if
  653. end
  654.  
  655. on endSprite me
  656.   hk.shutDown()
  657.   w.resetWorld()
  658. end
  659.