home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Payout.dxr / 00005_carScript.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  2.4 KB  |  69 lines

  1. property pPointList, pSpeed, pAngle, pPositionX, pPositionY, pChannel, pDestPoint, nextDestPoint, pFinished, totalDestPoints, pTripDistance, pTotalDistance, pNearEnd
  2. global gThePos, gShortestDistance
  3.  
  4. on new me, theSpeed, theAngle, thePosX, thePosY, thePointList, theChannel
  5.   pTripDistance = 0
  6.   pTotalDistance = 1000
  7.   totalDestPoints = 0
  8.   pFinished = 0
  9.   pDestPoint = 1
  10.   pSpeed = float(theSpeed)
  11.   pAngle = theAngle
  12.   pPositionX = float(thePosX)
  13.   pPositionY = float(thePosY)
  14.   pChannel = theChannel
  15.   pPointList = thePointList
  16.   nextDestPoint = pDestPoint + 1
  17.   if nextDestPoint > count(pPointList) then
  18.     nextDestPoint = 1
  19.   end if
  20.   pAngle = getAngle(pPositionX, pPositionY, pPointList[nextDestPoint][1], pPointList[nextDestPoint][2])
  21.   pNearEnd = 0
  22.   return me
  23. end
  24.  
  25. on updateCar me
  26.   pPositionX = pPositionX - (float(sin(pAngle * 3.14000000000000012 / 180.0)) * pSpeed)
  27.   pPositionY = pPositionY - (float(cos(pAngle * 3.14000000000000012 / 180.0)) * pSpeed)
  28.   pTripDistance = pTripDistance + pSpeed
  29.   if pFinished = 1 then
  30.     pSpeed = pSpeed - 0.20000000000000001
  31.   end if
  32.   if pSpeed < 0 then
  33.     pSpeed = 0
  34.   end if
  35.   if (pPositionX > (pPointList[nextDestPoint][1] - 7)) and (pPositionX < (pPointList[nextDestPoint][1] + 7)) and (pPositionY > (pPointList[nextDestPoint][2] - 7)) and (pPositionY < (pPointList[nextDestPoint][2] + 7)) then
  36.     totalDestPoints = totalDestPoints + 1
  37.     pDestPoint = nextDestPoint
  38.     nextDestPoint = pDestPoint + 1
  39.     if nextDestPoint > count(pPointList) then
  40.       nextDestPoint = 1
  41.     end if
  42.     pAngle = getAngle(pPositionX, pPositionY, pPointList[nextDestPoint][1], pPointList[nextDestPoint][2])
  43.     sprite(pChannel).rotation = 360 - pAngle
  44.     if (pFinished = 0) and (pNearEnd = 1) and sprite(pChannel).intersects(4) and (pFinished = 0) then
  45.       case pChannel of
  46.         15:
  47.           put "Red car crossed"
  48.         16:
  49.           put "Green car crossed"
  50.         17:
  51.           put "Purple car crossed"
  52.         18:
  53.           put "Blue car crossed"
  54.       end case
  55.       pFinished = 1
  56.     end if
  57.   end if
  58.   if (totalDestPoints mod 5) = 0 then
  59.     if (pTotalDistance - pTripDistance) > 800 then
  60.       pNearEnd = 0
  61.       var = float(pTotalDistance) / float(gShortestDistance)
  62.       pSpeed = float(float(random(2) * var / 2) + (3 * var)) + ((4 - float(gThePos[pChannel - 14])) / 5)
  63.     else
  64.       pNearEnd = 1
  65.     end if
  66.   end if
  67.   sprite(pChannel).loc = point(pPositionX, pPositionY)
  68. end
  69.