home *** CD-ROM | disk | FTP | other *** search
- global gPlayer, gCarList, gCurrTrack, gStartTime, gFinalRankings, gFinalPoints, gWorkDammit
-
- on prepareMovie
- p_Init()
- gCurrTrack = 1
- gFinalRankings = []
- gFinalPoints = [[100, 0], [101, 0], [102, 0], [105, 0]]
- gCarList = [#kane: [#speed: 7, #accel: 0.80000000000000004, #cornering: 6], #stoneCold: [#speed: 8, #accel: 0.29999999999999999, #cornering: 5], #rock: [#speed: 7, #accel: 0.59999999999999998, #cornering: 7], #undertaker: [#speed: 6, #accel: 1.0, #cornering: 8]]
- gPlayer = new(script("Player"), 105)
- gPlayer.setCar(#kane)
- gWorkDammit = 0
- end
-
- on reset
- t_Init(1, gCurrTrack)
- e_Init()
- gfx_Init()
- pickup_Init([105])
- member("Rank").text = "1"
- member("Lap").text = "1"
- put "0:00.00" into member "TheTime"
- end
-
- on startTheTimer
- gStartTime = the ticks
- end
-
- on updateTimer
- theTime = the ticks - gStartTime
- dispTime = convertTimeToString(theTime)
- put dispTime into member "TheTime"
- end
-
- on getTime
- return the ticks - gStartTime
- end
-
- on convertTimeToString theTime
- if theTime = "DNF" then
- return "DNF"
- end if
- theSeconds = theTime / 60
- theMinutes = theSeconds / 60
- theSeconds = theSeconds - (theMinutes * 60)
- theMilliseconds = theTime mod (theSeconds * 60)
- strMinutes = string(theMinutes)
- strSeconds = string(theSeconds)
- strMilliseconds = string(theMilliseconds)
- if length(strMinutes) < 2 then
- strMinutes = "0" & strMinutes
- end if
- if length(strSeconds) < 2 then
- strSeconds = "0" & strSeconds
- end if
- if length(strMilliseconds) < 2 then
- strMilliseconds = "0" & strMilliseconds
- end if
- if length(strMilliseconds) > 2 then
- strMilliseconds = strMilliseconds.char[1] & strMilliseconds.char[2]
- end if
- dispTime = strMinutes & ":" & strSeconds & "." & strMilliseconds
- return dispTime
- end
-
- on getCarInfo theCar
- info = [:]
- addProp(info, #carType, theCar)
- addProp(info, #speed, gCarList[theCar].speed)
- addProp(info, #acceleration, gCarList[theCar].accel)
- addProp(info, #cornering, gCarList[theCar].cornering)
- return info
- end
-
- on getAngle loc1, loc2
- deltaX = -1 * (loc2[1] - loc1[1])
- deltaY = -1 * (loc2[2] - loc1[2])
- if deltaY = 0 then
- if deltaX > 0 then
- return 0
- end if
- if deltaX < 0 then
- return 180
- end if
- end if
- if deltaX = 0 then
- deltaX = 0.01
- end if
- theAngle = atan(float(deltaY) / float(deltaX))
- theAngle = theAngle * 180 / PI
- if (deltaX < 0) and (deltaY > 0) then
- theAngle = 180 + theAngle
- else
- if (deltaX < 0) and (deltaY < 0) then
- theAngle = 180 + theAngle
- else
- if (deltaX > 0) and (deltaY < 0) then
- theAngle = 360 + theAngle
- end if
- end if
- end if
- theAngle = theAngle - 90
- if theAngle < 0 then
- theAngle = theAngle + 360
- end if
- return theAngle
- end
-
- on hitPoint thePoint, destPoint, dist
- diff = destPoint - thePoint
- if (abs(diff[1]) <= dist) and (abs(diff[2]) <= dist) then
- return 1
- end if
- return 0
- end
-
- on updateRanking
- global geEnemyList, carList
- carList = []
- add(carList, [gPlayer.pCheckPointNum, gPlayer.pLap, gPlayer.pLocation + point(300, 150), gPlayer.pMySpriteNum])
- repeat with n = 1 to count(geEnemyList)
- add(carList, [geEnemyList[n][10], geEnemyList[n][11], geEnemyList[n][3], geEnemyList[n][1]])
- end repeat
- repeat with i = 1 to count(carList) - 1
- repeat with j = i + 1 to count(carList)
- if carList[j][2] > carList[i][2] then
- tmp = carList[j]
- carList[j] = carList[i]
- carList[i] = tmp
- next repeat
- end if
- if carList[j][2] = carList[i][2] then
- if carList[j][1] > carList[i][1] then
- tmp = carList[j]
- carList[j] = carList[i]
- carList[i] = tmp
- next repeat
- end if
- if carList[j][1] = carList[i][1] then
- iDist = p_GetDistance(gPlayer.pCheckPoints[gCurrTrack][carList[i][1]], carList[i][3])
- jDist = p_GetDistance(gPlayer.pCheckPoints[gCurrTrack][carList[j][1]], carList[j][3])
- if jDist < iDist then
- tmp = carList[j]
- carList[j] = carList[i]
- carList[i] = tmp
- end if
- end if
- end if
- end repeat
- end repeat
- repeat with n = 1 to count(carList)
- if carList[n][4] = gPlayer.pMySpriteNum then
- gPlayer.setRank(n)
- exit repeat
- end if
- end repeat
- end
-
- on updateSpeedDisplay theSpeed
- sSpeed = string(theSpeed)
- if length(sSpeed) < 2 then
- sSpeed = "0" & sSpeed
- end if
- if length(sSpeed) < 3 then
- sSpeed = "0" & sSpeed
- end if
- hundreds = integer(char 1 of sSpeed) + 1
- tens = integer(char 2 of sSpeed) + 1
- ones = integer(char 3 of sSpeed) + 1
- sprite(409).memberNum = member(hundreds, "Numbers")
- sprite(410).memberNum = member(tens, "Numbers")
- sprite(411).memberNum = member(ones, "Numbers")
- end
-
- on updateDamageDisplay percentDamage
- theWidth = 107 * percentDamage
- sprite(406).width = theWidth
- end
-
- on updateNitroDisplay percentNitro
- theWidth = 59 * percentNitro
- sprite(407).width = 59 - theWidth
- end
-
- on registerPoints theSpriteNum, finalPosition
- repeat with n = 1 to count(gFinalPoints)
- if gFinalPoints[n][1] = theSpriteNum then
- thePoints = getPoints(finalPosition)
- gFinalPoints[n][2] = gFinalPoints[n][2] + thePoints
- return thePoints
- end if
- end repeat
- end
-
- on getPoints finalPos
- case finalPos of
- 1:
- return 400
- 2:
- return 300
- 3:
- return 200
- 4:
- return 100
- end case
- end
-