home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / WakeRace.dxr / Internal_7_Player.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  8.4 KB  |  292 lines

  1. property pMySpriteNum, pState, pLocation, pDrift, pAngle, pAcceleration, pbRaceOver, pLap, pLapTimes, pCheckPoints, pCheckPointNum, pRank, pDamage, pCrashTimer, pCrashVelocity, pCollisionSlot, pNitro, pInAirDimMod, pOrigDims, pCarType, acceleration, MAX_SPEED, TURNMOD
  2. global gCarList, gFinalRankings, gCurrTrack, gWorkDammit
  3.  
  4. on new me, mySpriteNum
  5.   pMySpriteNum = mySpriteNum
  6.   pState = #normal
  7.   pLocation = point(0, 0)
  8.   pDrift = 1.5
  9.   pAngle = 0.0
  10.   pAcceleration = 0.0
  11.   pDamage = 0.0
  12.   pNitro = 0
  13.   pbRaceOver = 0
  14.   pLap = 1
  15.   pLapTimes = []
  16.   pCheckPoints = [[point(1066, 649), point(588, 382), point(346, 333), point(1021, 313), point(816, 480), point(671, 590), point(422, 516), point(348, 686), point(741, 721)], [point(417, 737), point(457, 266), point(994, 717), point(962, 263), point(526, 649)], [point(404, 371), point(524, 263), point(563, 643), point(414, 520), point(328, 623), point(476, 734), point(920, 734), point(1022, 277), point(769, 285), point(850, 646), point(837, 448), point(553, 448)]]
  17.   pCheckPointNum = 1
  18.   pRank = 1
  19.   sprite(pMySpriteNum).loc = point(290, 220)
  20.   pCarType = #kane
  21.   MAX_SPEED = 8.0
  22.   acceleration = 7.0
  23.   TURNMOD = 0.0
  24.   pCollisionSlot = p_RegisterObject([pLocation + point(290, 220), point(0, 0), 14, 100.0, pMySpriteNum])
  25.   sound(3).volume = 190
  26.   return me
  27. end
  28.  
  29. on reset me
  30.   pCollisionSlot = p_RegisterObject([pLocation + point(290, 220), point(0, 0), 20, 100.0, pMySpriteNum])
  31.   pLap = 1
  32.   pNitro = 0
  33.   pState = #normal
  34.   pDamage = 0
  35.   pLapTimes = []
  36.   pbRaceOver = 0
  37.   pCheckPointNum = 1
  38. end
  39.  
  40. on update me
  41.   case pState of
  42.     #normal:
  43.       updateNormal()
  44.     #crash:
  45.       updateCrash()
  46.     #inAir:
  47.       updateInAir()
  48.   end case
  49.   checkPointCheck()
  50.   if pDamage > 90.0 then
  51.     gfx_CreateEffect(#smoke, pLocation + point(290, 220), 120, pLocation, 0, pMySpriteNum, 1)
  52.   end if
  53.   updateSpeedDisplay(integer(pAcceleration * 10))
  54. end
  55.  
  56. on updateNormal
  57.   if not pbRaceOver then
  58.     handleKeys()
  59.   else
  60.     if pAcceleration > 0.5 then
  61.       gfx_CreateEffect(#tireTrack, pLocation + point(290, 220), 120, pLocation, sprite(pMySpriteNum).rotation, pMySpriteNum, 0)
  62.     end if
  63.     pAcceleration = pAcceleration * 0.93000000000000005
  64.   end if
  65.   updateCar()
  66.   terrainType = t_GroundCheck(pLocation + point(290, 220))
  67.   adjustForTerrain(terrainType)
  68. end
  69.  
  70. on updateCrash
  71.   pLocation = pLocation + pCrashVelocity
  72.   pCrashVelocity = pCrashVelocity * 0.92000000000000004
  73.   handleKeys()
  74.   updateCar()
  75.   terrainType = t_GroundCheck(pLocation + point(290, 220))
  76.   adjustForTerrain(terrainType)
  77.   p_UpdateObject(pCollisionSlot, pLocation + point(290, 220), pCrashVelocity)
  78.   if the ticks > pCrashTimer then
  79.     pState = #normal
  80.   end if
  81. end
  82.  
  83. on updateInAir
  84.   updateCar()
  85.   sprite(pMySpriteNum).width = sprite(pMySpriteNum).width + pInAirDimMod
  86.   sprite(pMySpriteNum).height = sprite(pMySpriteNum).height + pInAirDimMod
  87.   if abs(pInAirDimMod) = 1.10000000000000009 then
  88.     maxWidth = 2
  89.   else
  90.     maxWidth = 15
  91.   end if
  92.   if (sprite(pMySpriteNum).width > (pOrigDims[1] + maxWidth)) and (pInAirDimMod > 0) then
  93.     pInAirDimMod = -pInAirDimMod
  94.     sprite(pMySpriteNum).member = member(string(pCarType))
  95.   end if
  96.   if (sprite(pMySpriteNum).width <= (pOrigDims[1] + (maxWidth / 2))) and (sprite(pMySpriteNum).member = member(string(pCarType))) then
  97.     sprite(pMySpriteNum).member = member(string(pCarType) & "Down")
  98.   end if
  99.   if sprite(pMySpriteNum).width <= pOrigDims[1] then
  100.     pState = #normal
  101.     sprite(pMySpriteNum).member = member(string(pCarType))
  102.     sprite(pMySpriteNum).width = pOrigDims[1]
  103.     sprite(pMySpriteNum).height = pOrigDims[2]
  104.   end if
  105. end
  106.  
  107. on handleKeys
  108.   bTurnKeyPressed = 0
  109.   if keyPressed(123) then
  110.     sprite(pMySpriteNum).rotation = sprite(pMySpriteNum).rotation - TURNMOD
  111.     bTurnKeyPressed = 1
  112.   end if
  113.   if keyPressed(124) then
  114.     sprite(pMySpriteNum).rotation = sprite(pMySpriteNum).rotation + TURNMOD
  115.     bTurnKeyPressed = 1
  116.   end if
  117.   if keyPressed(125) then
  118.     pAcceleration = pAcceleration - acceleration
  119.   end if
  120.   if keyPressed(126) then
  121.     gfx_CreateEffect(#tireTrack, pLocation + point(290, 220), 120, pLocation, sprite(pMySpriteNum).rotation, pMySpriteNum, 0)
  122.     if sound(3).isBusy() = 0 then
  123.       puppetSound(3, "engineLOOP")
  124.     end if
  125.     pAcceleration = pAcceleration + acceleration
  126.   else
  127.     if not keyPressed(126) then
  128.       sound(3).stop()
  129.       pAcceleration = pAcceleration * 0.95999999999999996
  130.     end if
  131.   end if
  132.   if pAcceleration < 0.0 then
  133.     pAcceleration = 0.0
  134.   end if
  135.   if pAcceleration > MAX_SPEED then
  136.     pAcceleration = MAX_SPEED
  137.   end if
  138.   if keyPressed(SPACE) then
  139.     if pNitro > 0 then
  140.       pAcceleration = pAcceleration + 5.0
  141.       pNitro = pNitro - 1
  142.       updateNitroDisplay(pNitro / 100.0)
  143.     end if
  144.   end if
  145. end
  146.  
  147. on updateCar
  148.   if pAcceleration < 1.0 then
  149.     if pAngle < (sprite(pMySpriteNum).rotation - pDrift) then
  150.       pAngle = pAngle + pDrift
  151.     else
  152.       if pAngle > (sprite(pMySpriteNum).rotation + pDrift) then
  153.         pAngle = pAngle - pDrift
  154.       else
  155.         pAngle = sprite(pMySpriteNum).rotation
  156.       end if
  157.     end if
  158.   else
  159.     pAngle = sprite(pMySpriteNum).rotation
  160.   end if
  161.   radAngle = pAngle * PI / 180
  162.   theOffset = point(sin(radAngle), -cos(radAngle)) * pAcceleration
  163.   pLocation = pLocation + theOffset
  164.   capLocation()
  165.   if gWorkDammit = 1 then
  166.     pLocation = pLocation - (theOffset * 2.04999999999999982)
  167.   end if
  168.   p_UpdateObject(pCollisionSlot, pLocation + point(290, 220), theOffset)
  169. end
  170.  
  171. on adjustForTerrain terrainType
  172.   case terrainType of
  173.     #track:
  174.       nothing()
  175.     #grass:
  176.       if pAcceleration > (MAX_SPEED / 2.5) then
  177.         pAcceleration = pAcceleration - 0.80000000000000004
  178.       end if
  179.       if pAcceleration > 1.0 then
  180.         gfx_CreateEffect(#dust, pLocation + point(290, 220), 120, pLocation, 0, pMySpriteNum, 1)
  181.       end if
  182.     #mediumRamp:
  183.       if pAcceleration > 1.0 then
  184.         pState = #inAir
  185.         pOrigDims = [sprite(pMySpriteNum).member.width, sprite(pMySpriteNum).member.height]
  186.         pInAirDimMod = 2
  187.         sprite(pMySpriteNum).member = member(string(pCarType) & "Up")
  188.       end if
  189.     #bigRamp:
  190.       if pAcceleration > 1.0 then
  191.         pState = #inAir
  192.         pOrigDims = [sprite(pMySpriteNum).member.width, sprite(pMySpriteNum).member.height]
  193.         pInAirDimMod = 1
  194.         sprite(pMySpriteNum).member = member(string(pCarType) & "Up")
  195.       end if
  196.     #inpassible:
  197.       gWorkDammit = 1
  198.       updateCar()
  199.       gWorkDammit = 0
  200.     #smallRamp:
  201.       if pAcceleration > 1.0 then
  202.         pState = #inAir
  203.         pOrigDims = [sprite(pMySpriteNum).member.width, sprite(pMySpriteNum).member.height]
  204.         pInAirDimMod = 1.10000000000000009
  205.         sprite(pMySpriteNum).member = member(string(pCarType) & "Up")
  206.       end if
  207.   end case
  208. end
  209.  
  210. on crash me, crashVel
  211.   if (pState = #normal) and not pbRaceOver then
  212.     pState = #crash
  213.     pCrashTimer = the ticks + 60
  214.     pCrashVelocity = crashVel
  215.     pAcceleration = 0.0
  216.     pDamage = pDamage + 7
  217.     updateDamageDisplay(pDamage / 100.0)
  218.     if pDamage >= 100 then
  219.       pDamage = 100
  220.       pbRaceOver = 1
  221.       go("RaceOver")
  222.     end if
  223.   end if
  224. end
  225.  
  226. on setCar me, theCar
  227.   pCarType = theCar
  228.   MAX_SPEED = gCarList[pCarType].speed
  229.   acceleration = gCarList[pCarType].accel
  230.   TURNMOD = gCarList[pCarType].cornering
  231.   sprite(pMySpriteNum).member = member(string(pCarType))
  232. end
  233.  
  234. on getCarType me
  235.   return pCarType
  236. end
  237.  
  238. on checkPointCheck
  239.   if hitPoint(pLocation + point(290, 220), pCheckPoints[gCurrTrack][pCheckPointNum], 30) then
  240.     pCheckPointNum = pCheckPointNum + 1
  241.     puppetSound(4, "pickup")
  242.     if pCheckPointNum > count(pCheckPoints[gCurrTrack]) then
  243.       pLap = pLap + 1
  244.       add(pLapTimes, getTime())
  245.       if pLap = 4 then
  246.         pCheckPointNum = 1
  247.         pbRaceOver = 1
  248.         add(gFinalRankings, pMySpriteNum)
  249.         go("RaceOver")
  250.       else
  251.         member("Lap").text = string(pLap)
  252.         pCheckPointNum = 1
  253.       end if
  254.     end if
  255.   end if
  256. end
  257.  
  258. on capLocation
  259.   if pLocation[1] < -46 then
  260.     pLocation[1] = -46
  261.   end if
  262.   if pLocation[1] > 860 then
  263.     pLocation[1] = 860
  264.   end if
  265.   if pLocation[2] < 10 then
  266.     pLocation[2] = 10
  267.   end if
  268.   if pLocation[2] > 552 then
  269.     pLocation[2] = 552
  270.   end if
  271. end
  272.  
  273. on setRank me, newRank
  274.   pRank = newRank
  275.   if not pbRaceOver then
  276.     if value(member("Rank").text) <> pRank then
  277.       member("Rank").text = string(pRank)
  278.     end if
  279.   end if
  280. end
  281.  
  282. on pickupObject me, objType
  283.   case objType of
  284.     #nitro:
  285.       pNitro = pNitro + 50
  286.       if pNitro > 100 then
  287.         pNitro = 100
  288.       end if
  289.       updateNitroDisplay(pNitro / 100.0)
  290.   end case
  291. end
  292.