home *** CD-ROM | disk | FTP | other *** search
- 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
- global gCarList, gFinalRankings, gCurrTrack, gWorkDammit
-
- on new me, mySpriteNum
- pMySpriteNum = mySpriteNum
- pState = #normal
- pLocation = point(0, 0)
- pDrift = 1.5
- pAngle = 0.0
- pAcceleration = 0.0
- pDamage = 0.0
- pNitro = 0
- pbRaceOver = 0
- pLap = 1
- pLapTimes = []
- 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)]]
- pCheckPointNum = 1
- pRank = 1
- sprite(pMySpriteNum).loc = point(290, 220)
- pCarType = #kane
- MAX_SPEED = 8.0
- acceleration = 7.0
- TURNMOD = 0.0
- pCollisionSlot = p_RegisterObject([pLocation + point(290, 220), point(0, 0), 14, 100.0, pMySpriteNum])
- sound(3).volume = 190
- return me
- end
-
- on reset me
- pCollisionSlot = p_RegisterObject([pLocation + point(290, 220), point(0, 0), 20, 100.0, pMySpriteNum])
- pLap = 1
- pNitro = 0
- pState = #normal
- pDamage = 0
- pLapTimes = []
- pbRaceOver = 0
- pCheckPointNum = 1
- end
-
- on update me
- case pState of
- #normal:
- updateNormal()
- #crash:
- updateCrash()
- #inAir:
- updateInAir()
- end case
- checkPointCheck()
- if pDamage > 90.0 then
- gfx_CreateEffect(#smoke, pLocation + point(290, 220), 120, pLocation, 0, pMySpriteNum, 1)
- end if
- updateSpeedDisplay(integer(pAcceleration * 10))
- end
-
- on updateNormal
- if not pbRaceOver then
- handleKeys()
- else
- if pAcceleration > 0.5 then
- gfx_CreateEffect(#tireTrack, pLocation + point(290, 220), 120, pLocation, sprite(pMySpriteNum).rotation, pMySpriteNum, 0)
- end if
- pAcceleration = pAcceleration * 0.93000000000000005
- end if
- updateCar()
- terrainType = t_GroundCheck(pLocation + point(290, 220))
- adjustForTerrain(terrainType)
- end
-
- on updateCrash
- pLocation = pLocation + pCrashVelocity
- pCrashVelocity = pCrashVelocity * 0.92000000000000004
- handleKeys()
- updateCar()
- terrainType = t_GroundCheck(pLocation + point(290, 220))
- adjustForTerrain(terrainType)
- p_UpdateObject(pCollisionSlot, pLocation + point(290, 220), pCrashVelocity)
- if the ticks > pCrashTimer then
- pState = #normal
- end if
- end
-
- on updateInAir
- updateCar()
- sprite(pMySpriteNum).width = sprite(pMySpriteNum).width + pInAirDimMod
- sprite(pMySpriteNum).height = sprite(pMySpriteNum).height + pInAirDimMod
- if abs(pInAirDimMod) = 1.10000000000000009 then
- maxWidth = 2
- else
- maxWidth = 15
- end if
- if (sprite(pMySpriteNum).width > (pOrigDims[1] + maxWidth)) and (pInAirDimMod > 0) then
- pInAirDimMod = -pInAirDimMod
- sprite(pMySpriteNum).member = member(string(pCarType))
- end if
- if (sprite(pMySpriteNum).width <= (pOrigDims[1] + (maxWidth / 2))) and (sprite(pMySpriteNum).member = member(string(pCarType))) then
- sprite(pMySpriteNum).member = member(string(pCarType) & "Down")
- end if
- if sprite(pMySpriteNum).width <= pOrigDims[1] then
- pState = #normal
- sprite(pMySpriteNum).member = member(string(pCarType))
- sprite(pMySpriteNum).width = pOrigDims[1]
- sprite(pMySpriteNum).height = pOrigDims[2]
- end if
- end
-
- on handleKeys
- bTurnKeyPressed = 0
- if keyPressed(123) then
- sprite(pMySpriteNum).rotation = sprite(pMySpriteNum).rotation - TURNMOD
- bTurnKeyPressed = 1
- end if
- if keyPressed(124) then
- sprite(pMySpriteNum).rotation = sprite(pMySpriteNum).rotation + TURNMOD
- bTurnKeyPressed = 1
- end if
- if keyPressed(125) then
- pAcceleration = pAcceleration - acceleration
- end if
- if keyPressed(126) then
- gfx_CreateEffect(#tireTrack, pLocation + point(290, 220), 120, pLocation, sprite(pMySpriteNum).rotation, pMySpriteNum, 0)
- if sound(3).isBusy() = 0 then
- puppetSound(3, "engineLOOP")
- end if
- pAcceleration = pAcceleration + acceleration
- else
- if not keyPressed(126) then
- sound(3).stop()
- pAcceleration = pAcceleration * 0.95999999999999996
- end if
- end if
- if pAcceleration < 0.0 then
- pAcceleration = 0.0
- end if
- if pAcceleration > MAX_SPEED then
- pAcceleration = MAX_SPEED
- end if
- if keyPressed(SPACE) then
- if pNitro > 0 then
- pAcceleration = pAcceleration + 5.0
- pNitro = pNitro - 1
- updateNitroDisplay(pNitro / 100.0)
- end if
- end if
- end
-
- on updateCar
- if pAcceleration < 1.0 then
- if pAngle < (sprite(pMySpriteNum).rotation - pDrift) then
- pAngle = pAngle + pDrift
- else
- if pAngle > (sprite(pMySpriteNum).rotation + pDrift) then
- pAngle = pAngle - pDrift
- else
- pAngle = sprite(pMySpriteNum).rotation
- end if
- end if
- else
- pAngle = sprite(pMySpriteNum).rotation
- end if
- radAngle = pAngle * PI / 180
- theOffset = point(sin(radAngle), -cos(radAngle)) * pAcceleration
- pLocation = pLocation + theOffset
- capLocation()
- if gWorkDammit = 1 then
- pLocation = pLocation - (theOffset * 2.04999999999999982)
- end if
- p_UpdateObject(pCollisionSlot, pLocation + point(290, 220), theOffset)
- end
-
- on adjustForTerrain terrainType
- case terrainType of
- #track:
- nothing()
- #grass:
- if pAcceleration > (MAX_SPEED / 2.5) then
- pAcceleration = pAcceleration - 0.80000000000000004
- end if
- if pAcceleration > 1.0 then
- gfx_CreateEffect(#dust, pLocation + point(290, 220), 120, pLocation, 0, pMySpriteNum, 1)
- end if
- #mediumRamp:
- if pAcceleration > 1.0 then
- pState = #inAir
- pOrigDims = [sprite(pMySpriteNum).member.width, sprite(pMySpriteNum).member.height]
- pInAirDimMod = 2
- sprite(pMySpriteNum).member = member(string(pCarType) & "Up")
- end if
- #bigRamp:
- if pAcceleration > 1.0 then
- pState = #inAir
- pOrigDims = [sprite(pMySpriteNum).member.width, sprite(pMySpriteNum).member.height]
- pInAirDimMod = 1
- sprite(pMySpriteNum).member = member(string(pCarType) & "Up")
- end if
- #inpassible:
- gWorkDammit = 1
- updateCar()
- gWorkDammit = 0
- #smallRamp:
- if pAcceleration > 1.0 then
- pState = #inAir
- pOrigDims = [sprite(pMySpriteNum).member.width, sprite(pMySpriteNum).member.height]
- pInAirDimMod = 1.10000000000000009
- sprite(pMySpriteNum).member = member(string(pCarType) & "Up")
- end if
- end case
- end
-
- on crash me, crashVel
- if (pState = #normal) and not pbRaceOver then
- pState = #crash
- pCrashTimer = the ticks + 60
- pCrashVelocity = crashVel
- pAcceleration = 0.0
- pDamage = pDamage + 7
- updateDamageDisplay(pDamage / 100.0)
- if pDamage >= 100 then
- pDamage = 100
- pbRaceOver = 1
- go("RaceOver")
- end if
- end if
- end
-
- on setCar me, theCar
- pCarType = theCar
- MAX_SPEED = gCarList[pCarType].speed
- acceleration = gCarList[pCarType].accel
- TURNMOD = gCarList[pCarType].cornering
- sprite(pMySpriteNum).member = member(string(pCarType))
- end
-
- on getCarType me
- return pCarType
- end
-
- on checkPointCheck
- if hitPoint(pLocation + point(290, 220), pCheckPoints[gCurrTrack][pCheckPointNum], 30) then
- pCheckPointNum = pCheckPointNum + 1
- puppetSound(4, "pickup")
- if pCheckPointNum > count(pCheckPoints[gCurrTrack]) then
- pLap = pLap + 1
- add(pLapTimes, getTime())
- if pLap = 4 then
- pCheckPointNum = 1
- pbRaceOver = 1
- add(gFinalRankings, pMySpriteNum)
- go("RaceOver")
- else
- member("Lap").text = string(pLap)
- pCheckPointNum = 1
- end if
- end if
- end if
- end
-
- on capLocation
- if pLocation[1] < -46 then
- pLocation[1] = -46
- end if
- if pLocation[1] > 860 then
- pLocation[1] = 860
- end if
- if pLocation[2] < 10 then
- pLocation[2] = 10
- end if
- if pLocation[2] > 552 then
- pLocation[2] = 552
- end if
- end
-
- on setRank me, newRank
- pRank = newRank
- if not pbRaceOver then
- if value(member("Rank").text) <> pRank then
- member("Rank").text = string(pRank)
- end if
- end if
- end
-
- on pickupObject me, objType
- case objType of
- #nitro:
- pNitro = pNitro + 50
- if pNitro > 100 then
- pNitro = 100
- end if
- updateNitroDisplay(pNitro / 100.0)
- end case
- end
-