home *** CD-ROM | disk | FTP | other *** search
Wrap
property pPointList, pSpeed, pAngle, pPositionX, pPositionY, pChannel, pDestPoint, nextDestPoint, pFinished, totalDestPoints, pTripDistance, pTotalDistance, pNearEnd global gThePos, gShortestDistance on new me, theSpeed, theAngle, thePosX, thePosY, thePointList, theChannel pTripDistance = 0 pTotalDistance = 1000 totalDestPoints = 0 pFinished = 0 pDestPoint = 1 pSpeed = float(theSpeed) pAngle = theAngle pPositionX = float(thePosX) pPositionY = float(thePosY) pChannel = theChannel pPointList = thePointList nextDestPoint = pDestPoint + 1 if nextDestPoint > count(pPointList) then nextDestPoint = 1 end if pAngle = getAngle(pPositionX, pPositionY, pPointList[nextDestPoint][1], pPointList[nextDestPoint][2]) pNearEnd = 0 return me end on updateCar me pPositionX = pPositionX - (float(sin(pAngle * 3.14000000000000012 / 180.0)) * pSpeed) pPositionY = pPositionY - (float(cos(pAngle * 3.14000000000000012 / 180.0)) * pSpeed) pTripDistance = pTripDistance + pSpeed if pFinished = 1 then pSpeed = pSpeed - 0.20000000000000001 end if if pSpeed < 0 then pSpeed = 0 end if 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 totalDestPoints = totalDestPoints + 1 pDestPoint = nextDestPoint nextDestPoint = pDestPoint + 1 if nextDestPoint > count(pPointList) then nextDestPoint = 1 end if pAngle = getAngle(pPositionX, pPositionY, pPointList[nextDestPoint][1], pPointList[nextDestPoint][2]) sprite(pChannel).rotation = 360 - pAngle if (pFinished = 0) and (pNearEnd = 1) and sprite(pChannel).intersects(4) and (pFinished = 0) then case pChannel of 15: put "Red car crossed" 16: put "Green car crossed" 17: put "Purple car crossed" 18: put "Blue car crossed" end case pFinished = 1 end if end if if (totalDestPoints mod 5) = 0 then if (pTotalDistance - pTripDistance) > 800 then pNearEnd = 0 var = float(pTotalDistance) / float(gShortestDistance) pSpeed = float(float(random(2) * var / 2) + (3 * var)) + ((4 - float(gThePos[pChannel - 14])) / 5) else pNearEnd = 1 end if end if sprite(pChannel).loc = point(pPositionX, pPositionY) end