home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / Payout.dxr / 00001.ls next >
Encoding:
Text File  |  2002-01-25  |  4.2 KB  |  154 lines

  1. global gThePos, gRaceStart, gShortestDistance, gMoney, gBet, gWinnings, gSelected, pList, pReset
  2.  
  3. on prepareMovie
  4.   pList = [2.0, 4.0, 5.0, 20.0]
  5.   gSelected = 0
  6.   gMoney = 100
  7.   gBet = 0
  8.   gWinnings = 0
  9. end
  10.  
  11. on function listOfOdds
  12.   listLenght = count(listOfOdds)
  13.   commonDeno = float(listOfOdds[listLenght])
  14.   sumOfNum = 0.0
  15.   counter = 0
  16.   positionList = []
  17.   repeat with counter = 1 to listLenght
  18.     append(positionList, 0.0)
  19.   end repeat
  20.   repeat with counter = 1 to listLenght
  21.     listOfOdds[counter] = float(commonDeno / listOfOdds[counter])
  22.     sumOfNum = float(sumOfNum + listOfOdds[counter])
  23.   end repeat
  24.   theMultiplier = float(commonDeno / sumOfNum)
  25.   repeat with counter = 1 to listLenght
  26.     listOfOdds[counter] = float(listOfOdds[counter] * theMultiplier * 10000)
  27.   end repeat
  28.   commonDeno = float(commonDeno * 10000)
  29.   repeat with counter = 1 to listLenght
  30.     randomNumber = random(commonDeno)
  31.     posFound = 0
  32.     adUp = 0.0
  33.     theCar = 1
  34.     repeat while posFound = 0
  35.       adUp = float(adUp + listOfOdds[theCar])
  36.       if (randomNumber <= integer(adUp)) and (randomNumber > 0) then
  37.         posFound = 1
  38.         commonDeno = commonDeno - listOfOdds[theCar]
  39.         listOfOdds[theCar] = 0.0
  40.         positionList[theCar] = counter
  41.       end if
  42.       theCar = theCar + 1
  43.     end repeat
  44.   end repeat
  45.   return positionList
  46. end
  47.  
  48. on getAngle x1, y1, x2, y2
  49.   loc1 = [x1, y1]
  50.   loc2 = [x2, y2]
  51.   deltaX = loc2[1] - loc1[1]
  52.   deltaY = -1 * (loc2[2] - loc1[2])
  53.   if deltaY = 0 then
  54.     if deltaX > 0 then
  55.       return 0
  56.     end if
  57.     if deltaX < 0 then
  58.       return 180
  59.     end if
  60.   end if
  61.   if deltaX = 0 then
  62.     deltaX = 0.01
  63.   end if
  64.   theAngle = atan(float(deltaY) / float(deltaX))
  65.   theAngle = theAngle * 180 / PI
  66.   if (deltaX < 0) and (deltaY > 0) then
  67.     theAngle = 180 + theAngle
  68.   else
  69.     if (deltaX < 0) and (deltaY < 0) then
  70.       theAngle = 180 + theAngle
  71.     else
  72.       if (deltaX > 0) and (deltaY < 0) then
  73.         theAngle = 360 + theAngle
  74.       end if
  75.     end if
  76.   end if
  77.   theAngle = theAngle - 90
  78.   if theAngle < 0 then
  79.     theAngle = 360 + theAngle
  80.   end if
  81.   return theAngle
  82. end
  83.  
  84. on getDistance point1X, point1Y, point2X, point2Y
  85.   distance1 = float(abs(point1X - point2X))
  86.   distance2 = float(abs(point1Y - point2Y))
  87.   hypo = sqrt((distance1 * distance1) + (distance2 * distance2))
  88.   return hypo
  89. end
  90.  
  91. on getTrackDistance listOfPoint
  92.   theDistance = 0.0
  93.   repeat with counter = 1 to count(listOfPoint) - 1
  94.     theDistance = theDistance + getDistance(listOfPoint[counter][1], listOfPoint[counter][2], listOfPoint[counter + 1][1], listOfPoint[counter + 1][2])
  95.   end repeat
  96.   theDistance = theDistance + getDistance(listOfPoint[1][1], listOfPoint[1][2], listOfPoint[count(listOfPoint)][1], listOfPoint[count(listOfPoint)][2])
  97.   return theDistance
  98. end
  99.  
  100. on resetAllCars
  101.   if (sprite(15).loc = point(494, 242)) and (sprite(16).loc = point(517, 242)) and (sprite(17).loc = point(543, 242)) and (sprite(18).loc = point(566, 242)) then
  102.     exit
  103.   end if
  104.   cTimer = the ticks
  105.   repeat while sprite(15).blend > 20
  106.     if (cTimer + 2) < the ticks then
  107.       cTimer = the ticks
  108.       sprite(15).blend = sprite(15).blend - 15
  109.       sprite(16).blend = sprite(16).blend - 15
  110.       sprite(17).blend = sprite(17).blend - 15
  111.       sprite(18).blend = sprite(18).blend - 15
  112.       updateStage()
  113.     end if
  114.   end repeat
  115.   sprite(15).loc = point(494, 242)
  116.   sprite(16).loc = point(517, 242)
  117.   sprite(17).loc = point(543, 242)
  118.   sprite(18).loc = point(566, 242)
  119.   sprite(15).rotation = 0
  120.   sprite(16).rotation = 0
  121.   sprite(17).rotation = 0
  122.   sprite(18).rotation = 0
  123.   cTimer = the ticks
  124.   repeat while sprite(15).blend < 80
  125.     if (cTimer + 2) < the ticks then
  126.       cTimer = the ticks
  127.       sprite(15).blend = sprite(15).blend + 15
  128.       sprite(16).blend = sprite(16).blend + 15
  129.       sprite(17).blend = sprite(17).blend + 15
  130.       sprite(18).blend = sprite(18).blend + 15
  131.       updateStage()
  132.     end if
  133.   end repeat
  134.   sprite(15).blend = 100
  135.   sprite(16).blend = 100
  136.   sprite(17).blend = 100
  137.   sprite(18).blend = 100
  138.   updateStage()
  139. end
  140.  
  141. on showAMessage theSprite
  142.   sprite(theSprite).blend = 100
  143.   updateStage()
  144.   counter = 0
  145.   TheTimer = the ticks
  146.   repeat while counter < 45
  147.     if (TheTimer + 2) < the ticks then
  148.       counter = counter + 1
  149.       TheTimer = the ticks
  150.     end if
  151.   end repeat
  152.   sprite(theSprite).blend = 0
  153. end
  154.