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

  1. global gPlayer, gCarList, gCurrTrack, gStartTime, gFinalRankings, gFinalPoints, gWorkDammit
  2.  
  3. on prepareMovie
  4.   p_Init()
  5.   gCurrTrack = 1
  6.   gFinalRankings = []
  7.   gFinalPoints = [[100, 0], [101, 0], [102, 0], [105, 0]]
  8.   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]]
  9.   gPlayer = new(script("Player"), 105)
  10.   gPlayer.setCar(#kane)
  11.   gWorkDammit = 0
  12. end
  13.  
  14. on reset
  15.   t_Init(1, gCurrTrack)
  16.   e_Init()
  17.   gfx_Init()
  18.   pickup_Init([105])
  19.   member("Rank").text = "1"
  20.   member("Lap").text = "1"
  21.   put "0:00.00" into member "TheTime"
  22. end
  23.  
  24. on startTheTimer
  25.   gStartTime = the ticks
  26. end
  27.  
  28. on updateTimer
  29.   theTime = the ticks - gStartTime
  30.   dispTime = convertTimeToString(theTime)
  31.   put dispTime into member "TheTime"
  32. end
  33.  
  34. on getTime
  35.   return the ticks - gStartTime
  36. end
  37.  
  38. on convertTimeToString theTime
  39.   if theTime = "DNF" then
  40.     return "DNF"
  41.   end if
  42.   theSeconds = theTime / 60
  43.   theMinutes = theSeconds / 60
  44.   theSeconds = theSeconds - (theMinutes * 60)
  45.   theMilliseconds = theTime mod (theSeconds * 60)
  46.   strMinutes = string(theMinutes)
  47.   strSeconds = string(theSeconds)
  48.   strMilliseconds = string(theMilliseconds)
  49.   if length(strMinutes) < 2 then
  50.     strMinutes = "0" & strMinutes
  51.   end if
  52.   if length(strSeconds) < 2 then
  53.     strSeconds = "0" & strSeconds
  54.   end if
  55.   if length(strMilliseconds) < 2 then
  56.     strMilliseconds = "0" & strMilliseconds
  57.   end if
  58.   if length(strMilliseconds) > 2 then
  59.     strMilliseconds = strMilliseconds.char[1] & strMilliseconds.char[2]
  60.   end if
  61.   dispTime = strMinutes & ":" & strSeconds & "." & strMilliseconds
  62.   return dispTime
  63. end
  64.  
  65. on getCarInfo theCar
  66.   info = [:]
  67.   addProp(info, #carType, theCar)
  68.   addProp(info, #speed, gCarList[theCar].speed)
  69.   addProp(info, #acceleration, gCarList[theCar].accel)
  70.   addProp(info, #cornering, gCarList[theCar].cornering)
  71.   return info
  72. end
  73.  
  74. on getAngle loc1, loc2
  75.   deltaX = -1 * (loc2[1] - loc1[1])
  76.   deltaY = -1 * (loc2[2] - loc1[2])
  77.   if deltaY = 0 then
  78.     if deltaX > 0 then
  79.       return 0
  80.     end if
  81.     if deltaX < 0 then
  82.       return 180
  83.     end if
  84.   end if
  85.   if deltaX = 0 then
  86.     deltaX = 0.01
  87.   end if
  88.   theAngle = atan(float(deltaY) / float(deltaX))
  89.   theAngle = theAngle * 180 / PI
  90.   if (deltaX < 0) and (deltaY > 0) then
  91.     theAngle = 180 + theAngle
  92.   else
  93.     if (deltaX < 0) and (deltaY < 0) then
  94.       theAngle = 180 + theAngle
  95.     else
  96.       if (deltaX > 0) and (deltaY < 0) then
  97.         theAngle = 360 + theAngle
  98.       end if
  99.     end if
  100.   end if
  101.   theAngle = theAngle - 90
  102.   if theAngle < 0 then
  103.     theAngle = theAngle + 360
  104.   end if
  105.   return theAngle
  106. end
  107.  
  108. on hitPoint thePoint, destPoint, dist
  109.   diff = destPoint - thePoint
  110.   if (abs(diff[1]) <= dist) and (abs(diff[2]) <= dist) then
  111.     return 1
  112.   end if
  113.   return 0
  114. end
  115.  
  116. on updateRanking
  117.   global geEnemyList, carList
  118.   carList = []
  119.   add(carList, [gPlayer.pCheckPointNum, gPlayer.pLap, gPlayer.pLocation + point(300, 150), gPlayer.pMySpriteNum])
  120.   repeat with n = 1 to count(geEnemyList)
  121.     add(carList, [geEnemyList[n][10], geEnemyList[n][11], geEnemyList[n][3], geEnemyList[n][1]])
  122.   end repeat
  123.   repeat with i = 1 to count(carList) - 1
  124.     repeat with j = i + 1 to count(carList)
  125.       if carList[j][2] > carList[i][2] then
  126.         tmp = carList[j]
  127.         carList[j] = carList[i]
  128.         carList[i] = tmp
  129.         next repeat
  130.       end if
  131.       if carList[j][2] = carList[i][2] then
  132.         if carList[j][1] > carList[i][1] then
  133.           tmp = carList[j]
  134.           carList[j] = carList[i]
  135.           carList[i] = tmp
  136.           next repeat
  137.         end if
  138.         if carList[j][1] = carList[i][1] then
  139.           iDist = p_GetDistance(gPlayer.pCheckPoints[gCurrTrack][carList[i][1]], carList[i][3])
  140.           jDist = p_GetDistance(gPlayer.pCheckPoints[gCurrTrack][carList[j][1]], carList[j][3])
  141.           if jDist < iDist then
  142.             tmp = carList[j]
  143.             carList[j] = carList[i]
  144.             carList[i] = tmp
  145.           end if
  146.         end if
  147.       end if
  148.     end repeat
  149.   end repeat
  150.   repeat with n = 1 to count(carList)
  151.     if carList[n][4] = gPlayer.pMySpriteNum then
  152.       gPlayer.setRank(n)
  153.       exit repeat
  154.     end if
  155.   end repeat
  156. end
  157.  
  158. on updateSpeedDisplay theSpeed
  159.   sSpeed = string(theSpeed)
  160.   if length(sSpeed) < 2 then
  161.     sSpeed = "0" & sSpeed
  162.   end if
  163.   if length(sSpeed) < 3 then
  164.     sSpeed = "0" & sSpeed
  165.   end if
  166.   hundreds = integer(char 1 of sSpeed) + 1
  167.   tens = integer(char 2 of sSpeed) + 1
  168.   ones = integer(char 3 of sSpeed) + 1
  169.   sprite(409).memberNum = member(hundreds, "Numbers")
  170.   sprite(410).memberNum = member(tens, "Numbers")
  171.   sprite(411).memberNum = member(ones, "Numbers")
  172. end
  173.  
  174. on updateDamageDisplay percentDamage
  175.   theWidth = 107 * percentDamage
  176.   sprite(406).width = theWidth
  177. end
  178.  
  179. on updateNitroDisplay percentNitro
  180.   theWidth = 59 * percentNitro
  181.   sprite(407).width = 59 - theWidth
  182. end
  183.  
  184. on registerPoints theSpriteNum, finalPosition
  185.   repeat with n = 1 to count(gFinalPoints)
  186.     if gFinalPoints[n][1] = theSpriteNum then
  187.       thePoints = getPoints(finalPosition)
  188.       gFinalPoints[n][2] = gFinalPoints[n][2] + thePoints
  189.       return thePoints
  190.     end if
  191.   end repeat
  192. end
  193.  
  194. on getPoints finalPos
  195.   case finalPos of
  196.     1:
  197.       return 400
  198.     2:
  199.       return 300
  200.     3:
  201.       return 200
  202.     4:
  203.       return 100
  204.   end case
  205. end
  206.