home *** CD-ROM | disk | FTP | other *** search
Wrap
global gThePos, gRaceStart, gShortestDistance, gMoney, gBet, gWinnings, gSelected, pList, pReset on prepareMovie pList = [2.0, 4.0, 5.0, 20.0] gSelected = 0 gMoney = 100 gBet = 0 gWinnings = 0 end on function listOfOdds listLenght = count(listOfOdds) commonDeno = float(listOfOdds[listLenght]) sumOfNum = 0.0 counter = 0 positionList = [] repeat with counter = 1 to listLenght append(positionList, 0.0) end repeat repeat with counter = 1 to listLenght listOfOdds[counter] = float(commonDeno / listOfOdds[counter]) sumOfNum = float(sumOfNum + listOfOdds[counter]) end repeat theMultiplier = float(commonDeno / sumOfNum) repeat with counter = 1 to listLenght listOfOdds[counter] = float(listOfOdds[counter] * theMultiplier * 10000) end repeat commonDeno = float(commonDeno * 10000) repeat with counter = 1 to listLenght randomNumber = random(commonDeno) posFound = 0 adUp = 0.0 theCar = 1 repeat while posFound = 0 adUp = float(adUp + listOfOdds[theCar]) if (randomNumber <= integer(adUp)) and (randomNumber > 0) then posFound = 1 commonDeno = commonDeno - listOfOdds[theCar] listOfOdds[theCar] = 0.0 positionList[theCar] = counter end if theCar = theCar + 1 end repeat end repeat return positionList end on getAngle x1, y1, x2, y2 loc1 = [x1, y1] loc2 = [x2, y2] deltaX = 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 = 360 + theAngle end if return theAngle end on getDistance point1X, point1Y, point2X, point2Y distance1 = float(abs(point1X - point2X)) distance2 = float(abs(point1Y - point2Y)) hypo = sqrt((distance1 * distance1) + (distance2 * distance2)) return hypo end on getTrackDistance listOfPoint theDistance = 0.0 repeat with counter = 1 to count(listOfPoint) - 1 theDistance = theDistance + getDistance(listOfPoint[counter][1], listOfPoint[counter][2], listOfPoint[counter + 1][1], listOfPoint[counter + 1][2]) end repeat theDistance = theDistance + getDistance(listOfPoint[1][1], listOfPoint[1][2], listOfPoint[count(listOfPoint)][1], listOfPoint[count(listOfPoint)][2]) return theDistance end on resetAllCars 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 exit end if cTimer = the ticks repeat while sprite(15).blend > 20 if (cTimer + 2) < the ticks then cTimer = the ticks sprite(15).blend = sprite(15).blend - 15 sprite(16).blend = sprite(16).blend - 15 sprite(17).blend = sprite(17).blend - 15 sprite(18).blend = sprite(18).blend - 15 updateStage() end if end repeat sprite(15).loc = point(494, 242) sprite(16).loc = point(517, 242) sprite(17).loc = point(543, 242) sprite(18).loc = point(566, 242) sprite(15).rotation = 0 sprite(16).rotation = 0 sprite(17).rotation = 0 sprite(18).rotation = 0 cTimer = the ticks repeat while sprite(15).blend < 80 if (cTimer + 2) < the ticks then cTimer = the ticks sprite(15).blend = sprite(15).blend + 15 sprite(16).blend = sprite(16).blend + 15 sprite(17).blend = sprite(17).blend + 15 sprite(18).blend = sprite(18).blend + 15 updateStage() end if end repeat sprite(15).blend = 100 sprite(16).blend = 100 sprite(17).blend = 100 sprite(18).blend = 100 updateStage() end on showAMessage theSprite sprite(theSprite).blend = 100 updateStage() counter = 0 TheTimer = the ticks repeat while counter < 45 if (TheTimer + 2) < the ticks then counter = counter + 1 TheTimer = the ticks end if end repeat sprite(theSprite).blend = 0 end