home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / MachineWar.dxr / 00002_Globals.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  9.0 KB  |  242 lines

  1. global gCurrentLevel, gTotalScore, gTheMouseDownSprite, gBombList, gPlayer1, gPlayer2, gPlayer3, gEnemy1, gEnemy2, gEnemy3, pCheezeHasBeenMoved, gThePad, gPath, gTotalHealth, gFlagSeised, pThePoint, gPathNetwork, gPointPositions, doChopper
  2.  
  3. on prepareMovie me
  4.   doChopper = 0
  5.   gPointPositions = [point(264, 400), point(414, 331), point(517, 403), point(110, 404), point(33, 196), point(192, 77), point(493, 91)]
  6.   pointList = [point(264, 400), point(414, 331)]
  7.   gPathNetwork = [new(script("Path"), pointList, pointList[1], pointList[2], 1, 2)]
  8.   pointList = [point(414, 331), point(425, 335), point(499, 374), point(509, 383), point(513, 393), point(517, 403)]
  9.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[6], 2, 3))
  10.   pointList = [point(414, 331), point(413, 314), point(408, 304), point(368, 211), point(369, 190), point(368, 178), point(367, 168), point(359, 157), point(341, 150), point(307, 139), point(204, 89), point(192, 77)]
  11.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[12], 2, 6))
  12.   pointList = [point(192, 77), point(205, 75), point(277, 109), point(370, 137), point(379, 137), point(393, 135), point(405, 131), point(493, 91)]
  13.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[8], 6, 7))
  14.   pointList = [point(192, 77), point(186, 86), point(246, 139), point(252, 152), point(251, 166), point(118, 399), point(110, 404)]
  15.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[7], 6, 4))
  16.   pointList = [point(110, 404), point(264, 400)]
  17.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[2], 4, 1))
  18.   pointList = [point(110, 404), point(101, 404), point(88, 396), point(21, 292), point(18, 276), point(14, 259), point(19, 244), point(26, 233), point(37, 222), point(37, 211), point(33, 196)]
  19.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[11], 4, 5))
  20.   pointList = [point(192, 77), point(33, 196)]
  21.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[2], 6, 5))
  22.   pointList = [point(33, 196), point(20, 168), point(16, 159), point(11, 83), point(10, 62), point(13, 45), point(21, 28), point(45, 21), point(65, 21), point(83, 24), point(185, 61), point(192, 77)]
  23.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[12], 5, 6))
  24.   pointList = [point(517, 403), point(493, 91)]
  25.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[2], 3, 7))
  26.   pointList = [point(192, 77), point(493, 91)]
  27.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[2], 6, 7))
  28.   pointList = [point(264, 400), point(286, 317), point(290, 300), point(294, 288), point(303, 266), point(307, 248), point(304, 227), point(299, 211), point(290, 194), point(281, 180), point(273, 171), point(192, 77)]
  29.   append(gPathNetwork, new(script("Path"), pointList, pointList[1], pointList[12], 1, 6))
  30.   gTotalHealth = 0
  31.   gTotalScore = 0
  32.   gCurrentLevel = 0
  33.   gTotalScore = 0
  34. end
  35.  
  36. on displayScore
  37.   member("ScoreDisplay").text = string(gTotalScore)
  38. end
  39.  
  40. on displayLevel
  41.   member("LevelDisplay").text = string(gCurrentLevel)
  42. end
  43.  
  44. on checkIfNodeThere theNode
  45.   there = 0
  46.   repeat with counter = 1 to count(gPath)
  47.     if gPath[counter] = theNode then
  48.       there = 1
  49.     end if
  50.   end repeat
  51.   return there
  52. end
  53.  
  54. on getNextSprite
  55.   gPlayer1.setAntDeSelected()
  56.   gPlayer2.setAntDeSelected()
  57.   gPlayer3.setAntDeSelected()
  58.   gSelectedSprite = gSelectedSprite + 1
  59.   if gSelectedSprite > 52 then
  60.     gSelectedSprite = 50
  61.   end if
  62.   case gSelectedSprite of
  63.     50:
  64.       if gPlayer1.pState = 3 then
  65.         getNextSprite()
  66.         exit
  67.       end if
  68.     51:
  69.       if gPlayer2.pState = 3 then
  70.         getNextSprite()
  71.         exit
  72.       end if
  73.     52:
  74.       if gPlayer3.pState = 3 then
  75.         getNextSprite()
  76.         exit
  77.       end if
  78.   end case
  79.   case gSelectedSprite of
  80.     50:
  81.       gPlayer1.setAntSelected()
  82.     51:
  83.       gPlayer2.setAntSelected()
  84.     52:
  85.       gPlayer3.setAntSelected()
  86.     otherwise:
  87.       sprite(16).blend = 0
  88.       gSelectedSprite = 0
  89.   end case
  90.   sprite(16).loc = sprite(gSelectedSprite).loc
  91. end
  92.  
  93. on makeSpriteFlash spriteNumber
  94.   if sprite(spriteNumber).blend = 100 then
  95.     sprite(spriteNumber).blend = 0
  96.     return 0
  97.   else
  98.     sprite(spriteNumber).blend = 100
  99.     return 1
  100.   end if
  101. end
  102.  
  103. on getAngle x1, y1, x2, y2
  104.   loc1 = [x1, y1]
  105.   loc2 = [x2, y2]
  106.   deltaX = loc2[1] - loc1[1]
  107.   deltaY = -1 * (loc2[2] - loc1[2])
  108.   if deltaY = 0 then
  109.     if deltaX > 0 then
  110.       return 0
  111.     end if
  112.     if deltaX < 0 then
  113.       return 180
  114.     end if
  115.   end if
  116.   if deltaX = 0 then
  117.     deltaX = 0.01
  118.   end if
  119.   theAngle = atan(float(deltaY) / float(deltaX))
  120.   theAngle = theAngle * 180 / PI
  121.   if (deltaX < 0) and (deltaY > 0) then
  122.     theAngle = 180 + theAngle
  123.   else
  124.     if (deltaX < 0) and (deltaY < 0) then
  125.       theAngle = 180 + theAngle
  126.     else
  127.       if (deltaX > 0) and (deltaY < 0) then
  128.         theAngle = 360 + theAngle
  129.       end if
  130.     end if
  131.   end if
  132.   theAngle = theAngle - 90
  133.   if theAngle < 0 then
  134.     theAngle = 360 + theAngle
  135.   end if
  136.   return theAngle
  137. end
  138.  
  139. on getDistance point1X, point1Y, point2X, point2Y
  140.   distance1 = float(abs(point1X - point2X))
  141.   distance2 = float(abs(point1Y - point2Y))
  142.   hypo = sqrt((distance1 * distance1) + (distance2 * distance2))
  143.   return hypo
  144. end
  145.  
  146. on getTrackDistance listOfPoint
  147.   theDistance = 0.0
  148.   repeat with counter = 1 to count(listOfPoint) - 1
  149.     theDistance = theDistance + getDistance(listOfPoint[counter][1], listOfPoint[counter][2], listOfPoint[counter + 1][1], listOfPoint[counter + 1][2])
  150.   end repeat
  151.   theDistance = theDistance + getDistance(listOfPoint[1][1], listOfPoint[1][2], listOfPoint[count(listOfPoint)][1], listOfPoint[count(listOfPoint)][2])
  152.   return theDistance
  153. end
  154.  
  155. on getIdealAveragePoint point1, point2, point3, point4
  156.   centerX = 0.5
  157.   centerY = 0.5
  158.   x = (float(point1[1]) * ((-0.5 * centerX * centerX * centerX) + (centerX * centerX) - (0.5 * centerX))) + (float(point2[1]) * ((1.5 * centerX * centerX * centerX) - (2.5 * centerX * centerX) + 1.0)) + (float(point3[1]) * ((-1.5 * centerX * centerX * centerX) + (2.0 * centerX * centerX) + (0.5 * centerX))) + (float(point4[1]) * ((0.5 * centerX * centerX * centerX) - (0.5 * centerX * centerX)))
  159.   y = (float(point1[2]) * ((-0.5 * centerY * centerY * centerY) + (centerY * centerY) - (0.5 * centerY))) + (float(point2[2]) * ((1.5 * centerY * centerY * centerY) - (2.5 * centerY * centerY) + 1.0)) + (float(point3[2]) * ((-1.5 * centerY * centerY * centerY) + (2.0 * centerY * centerY) + (0.5 * centerY))) + (float(point4[2]) * ((0.5 * centerY * centerY * centerY) - (0.5 * centerY * centerY)))
  160.   thePoint = point(x, y)
  161.   return thePoint
  162. end
  163.  
  164. on idealPath thePath
  165.   if count(thePath) <= 2 then
  166.     return duplicate(thePath)
  167.   end if
  168.   newPoints = []
  169.   if count(thePath) = 3 then
  170.     addAt(thePath, 2, getIdealAveragePoint(thePath[1], thePath[1], thePath[2], thePath[3]))
  171.     addAt(thePath, 4, getIdealAveragePoint(thePath[1], thePath[3], thePath[4], thePath[4]))
  172.   else
  173.     addAt(newPoints, 1, getIdealAveragePoint(thePath[1], thePath[1], thePath[2], thePath[3]))
  174.     repeat with counter = 2 to count(thePath) - 2
  175.       addAt(newPoints, counter, getIdealAveragePoint(thePath[counter - 1], thePath[counter], thePath[counter + 1], thePath[counter + 2]))
  176.     end repeat
  177.     addAt(newPoints, count(thePath) - 1, getIdealAveragePoint(thePath[count(thePath) - 2], thePath[count(thePath) - 1], thePath[count(thePath)], thePath[count(thePath)]))
  178.     counter2 = 2
  179.     repeat with counter = 1 to count(newPoints)
  180.       addAt(thePath, counter2, newPoints[counter])
  181.       counter2 = counter2 + 2
  182.     end repeat
  183.   end if
  184.   return duplicate(thePath)
  185. end
  186.  
  187. on spriteColision spriteRect, objectSpriteNum
  188.   colRect = intersect(spriteRect, sprite(objectSpriteNum).rect)
  189.   if colRect = rect(0, 0, 0, 0) then
  190.     return 0
  191.   end if
  192.   x1 = colRect.left - sprite(objectSpriteNum).rect.left
  193.   x2 = colRect.right - sprite(objectSpriteNum).rect.left
  194.   y1 = colRect.top - sprite(objectSpriteNum).rect.top
  195.   y2 = colRect.bottom - sprite(objectSpriteNum).rect.top
  196.   repeat with x = x1 to x2
  197.     x = x + 3
  198.     theColor = sprite(objectSpriteNum).member.image.getPixel(x, y1)
  199.     if theColor = rgb(248, 0, 0) then
  200.       return 2
  201.       next repeat
  202.     end if
  203.     if theColor = rgb(0, 248, 0) then
  204.       return 1
  205.     end if
  206.   end repeat
  207.   repeat with x = x1 to x2
  208.     x = x + 3
  209.     theColor = sprite(objectSpriteNum).member.image.getPixel(x, y1)
  210.     if theColor = rgb(248, 0, 0) then
  211.       return 2
  212.       next repeat
  213.     end if
  214.     if theColor = rgb(0, 248, 0) then
  215.       return 1
  216.     end if
  217.   end repeat
  218.   repeat with y = y1 to y2
  219.     y = y + 3
  220.     theColor = sprite(objectSpriteNum).member.image.getPixel(x, y1)
  221.     if theColor = rgb(248, 0, 0) then
  222.       return 2
  223.       next repeat
  224.     end if
  225.     if theColor = rgb(0, 248, 0) then
  226.       return 1
  227.     end if
  228.   end repeat
  229.   repeat with y = y1 to y2
  230.     y = y + 3
  231.     theColor = sprite(objectSpriteNum).member.image.getPixel(x, y1)
  232.     if theColor = rgb(248, 0, 0) then
  233.       return 2
  234.       next repeat
  235.     end if
  236.     if theColor = rgb(0, 248, 0) then
  237.       return 1
  238.     end if
  239.   end repeat
  240.   return 0
  241. end
  242.