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

  1. global gCurrentLevel, gTotalScore, gTheMouseDownSprite, gSelectedSprite, gBombList, gPlayer1, gPlayer2, gPlayer3, gEnemy1, gEnemy2, gEnemy3, gInfluence, gPath, gTotalHealth
  2.  
  3. on prepareMovie me
  4.   gTotalHealth = 0
  5.   gTotalScore = 0
  6.   member("ScoreDisplay").text = string(gTotalScore)
  7.   gInfluence = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 1, 1, 1, 1, 1], [1, 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 1, 1, 1, 1, 1], [1, 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, 1, 9, 9, 9, 9, 1, 1, 9, 9, 1, 1], [1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 9, 9, 9, 9, 1], [1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, 1, 9, 9, 9, 9, 1], [1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 9, 1, 1, 1], [1, 1, 1, 1, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 1, 1], [1, 1, 1, 1, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 1, 1], [1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, 9, 9, 9, 1, 1], [1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 1, 1, 1, 1], [9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 1, 1, 1, 1], [9, 9, 9, 9, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]
  8.   gCurrentLevel = 0
  9.   gTotalScore = 0
  10. end
  11.  
  12. on displayScore
  13.   member("ScoreDisplay").text = string(gTotalScore)
  14. end
  15.  
  16. on displayLevel
  17.   member("LevelDisplay").text = string(gCurrentLevel)
  18. end
  19.  
  20. on pathFind x1, y1, x2, y2
  21.   found = 0
  22.   gPath = [0]
  23.   curNode = [x1, y1]
  24.   gPath[1] = curNode
  25.   curX = x1
  26.   curY = y1
  27.   repeat while found = 0
  28.     if curX < x2 then
  29.       nextX = curX + 1
  30.     else
  31.       if curX > x2 then
  32.         nextX = curX - 1
  33.       else
  34.         nextX = curX
  35.       end if
  36.     end if
  37.     if curY < y2 then
  38.       nextY = curY + 1
  39.     else
  40.       if curY > y2 then
  41.         nextY = curY - 1
  42.       else
  43.         nextY = curY
  44.       end if
  45.     end if
  46.     if nextX <= 0 then
  47.       nextX = 1
  48.     end if
  49.     if nextY <= 0 then
  50.       nextY = 1
  51.     end if
  52.     if nextX > 22 then
  53.       nextX = 22
  54.     end if
  55.     if nextY > 22 then
  56.       nextY = 22
  57.     end if
  58.     curNode = [nextX, nextY]
  59.     if (gInfluence[nextY][nextX] >= 9) or checkIfNodeThere(curNode) then
  60.       nextX = curX + 1
  61.       if curY < y2 then
  62.         nextY = curY + 1
  63.       else
  64.         if curY > y2 then
  65.           nextY = curY - 1
  66.         else
  67.           nextY = curY
  68.         end if
  69.       end if
  70.       if nextX <= 0 then
  71.         nextX = 1
  72.       end if
  73.       if nextY <= 0 then
  74.         nextY = 1
  75.       end if
  76.       if nextX > 22 then
  77.         nextX = 22
  78.       end if
  79.       if nextY > 22 then
  80.         nextY = 22
  81.       end if
  82.       curNode = [nextX, nextY]
  83.       if (gInfluence[nextY][nextX] >= 9) or checkIfNodeThere(curNode) then
  84.         nextX = curX - 1
  85.         if curY < y2 then
  86.           nextY = curY + 1
  87.         else
  88.           if curY > y2 then
  89.             nextY = curY - 1
  90.           else
  91.             nextY = curY
  92.           end if
  93.         end if
  94.         if nextX <= 0 then
  95.           nextX = 1
  96.         end if
  97.         if nextY <= 0 then
  98.           nextY = 1
  99.         end if
  100.         if nextX > 22 then
  101.           nextX = 22
  102.         end if
  103.         if nextY > 22 then
  104.           nextY = 22
  105.         end if
  106.         curNode = [nextX, nextY]
  107.         if (gInfluence[nextY][nextX] >= 9) or checkIfNodeThere(curNode) then
  108.           nextX = curX
  109.           if curY < y2 then
  110.             nextY = curY + 1
  111.           else
  112.             if curY > y2 then
  113.               nextY = curY - 1
  114.             else
  115.               nexY = curY
  116.             end if
  117.           end if
  118.           if nextX <= 0 then
  119.             nextX = 1
  120.           end if
  121.           if nextY <= 0 then
  122.             nextY = 1
  123.           end if
  124.           if nextX > 22 then
  125.             nextX = 22
  126.           end if
  127.           if nextY > 22 then
  128.             nextY = 22
  129.           end if
  130.           curNode = [nextX, nextY]
  131.           if (gInfluence[nextY][nextX] >= 9) or checkIfNodeThere(curNode) then
  132.             nextX = curX - 1
  133.             nextY = curY
  134.             if nextX <= 0 then
  135.               nextX = 1
  136.             end if
  137.             if nextY <= 0 then
  138.               nextY = 1
  139.             end if
  140.             if nextX > 22 then
  141.               nextX = 22
  142.             end if
  143.             if nextY > 22 then
  144.               nextY = 22
  145.             end if
  146.             curNode = [nextX, nextY]
  147.             if (gInfluence[nextY][nextX] >= 9) or checkIfNodeThere(curNode) then
  148.               nextX = curX + 1
  149.               nextY = curY
  150.               if nextX <= 0 then
  151.                 nextX = 1
  152.               end if
  153.               if nextY <= 0 then
  154.                 nextY = 1
  155.               end if
  156.               if nextX > 22 then
  157.                 nextX = 22
  158.               end if
  159.               if nextY > 22 then
  160.                 nextY = 22
  161.               end if
  162.               curNode = [nextX, nextY]
  163.               if (gInfluence[nextY][nextX] >= 9) or checkIfNodeThere(curNode) then
  164.                 if curX < x2 then
  165.                   nextX = curX + 1
  166.                 else
  167.                   if curX > x2 then
  168.                     nextX = curX - 1
  169.                   else
  170.                     nextX = curX
  171.                   end if
  172.                 end if
  173.                 nextY = curY - 1
  174.                 if nextX <= 0 then
  175.                   nextX = 1
  176.                 end if
  177.                 if nextY <= 0 then
  178.                   nextY = 1
  179.                 end if
  180.                 if nextX > 22 then
  181.                   nextX = 22
  182.                 end if
  183.                 if nextY > 22 then
  184.                   nextY = 22
  185.                 end if
  186.                 curNode = [nextX, nextY]
  187.                 if (gInfluence[nextY][nextX] >= 9) or checkIfNodeThere(curNode) then
  188.                   if curX < x2 then
  189.                     nextX = curX + 1
  190.                   else
  191.                     if curX > x2 then
  192.                       nextX = curX - 1
  193.                     else
  194.                       nextX = curX
  195.                     end if
  196.                   end if
  197.                   nextY = curY + 1
  198.                   if nextX <= 0 then
  199.                     nextX = 1
  200.                   end if
  201.                   if nextY <= 0 then
  202.                     nextY = 1
  203.                   end if
  204.                   if nextX > 22 then
  205.                     nextX = 22
  206.                   end if
  207.                   if nextY > 22 then
  208.                     nextY = 22
  209.                   end if
  210.                   curNode = [nextX, nextY]
  211.                   if (gInfluence[nextY][nextX] >= 9) or checkIfNodeThere(curNode) then
  212.                     nextX = curX - 1
  213.                     if curY < y2 then
  214.                       nextY = curY - 1
  215.                     else
  216.                       if curY > y2 then
  217.                         nextY = curY + 1
  218.                       else
  219.                         nextY = curY
  220.                       end if
  221.                     end if
  222.                     if nextX <= 0 then
  223.                       nextX = 1
  224.                     end if
  225.                     if nextY <= 0 then
  226.                       nextY = 1
  227.                     end if
  228.                     if nextX > 22 then
  229.                       nextX = 22
  230.                     end if
  231.                     if nextY > 22 then
  232.                       nextY = 22
  233.                     end if
  234.                     curNode = [nextX, nextY]
  235.                     if (gInfluence[nextY][nextX] >= 9) or checkIfNodeThere(curNode) then
  236.                       nextX = curX + 1
  237.                       if curY < y2 then
  238.                         nextY = curY + 1
  239.                       else
  240.                         if curY > y2 then
  241.                           nextY = curY - 1
  242.                         else
  243.                           nextY = curY
  244.                         end if
  245.                       end if
  246.                       if nextX <= 0 then
  247.                         nextX = 1
  248.                       end if
  249.                       if nextY <= 0 then
  250.                         nextY = 1
  251.                       end if
  252.                       if nextX > 22 then
  253.                         nextX = 22
  254.                       end if
  255.                       if nextY > 22 then
  256.                         nextY = 22
  257.                       end if
  258.                       curNode = [nextX, nextY]
  259.                       if (gInfluence[nextY][nextX] >= 9) or checkIfNodeThere(curNode) then
  260.                         nextX = curX
  261.                         if curY < y2 then
  262.                           nextY = curY + 1
  263.                         else
  264.                           if curY > y2 then
  265.                             nextY = curY - 1
  266.                           else
  267.                             nextY = curY
  268.                           end if
  269.                         end if
  270.                         if nextX <= 0 then
  271.                           nextX = 1
  272.                         end if
  273.                         if nextY <= 0 then
  274.                           nextY = 1
  275.                         end if
  276.                         if nextX > 22 then
  277.                           nextX = 22
  278.                         end if
  279.                         if nextY > 22 then
  280.                           nextY = 22
  281.                         end if
  282.                         curNode = [nextX, nextY]
  283.                         if checkIfNodeThere(curNode) = 1 then
  284.                           gPath = [0]
  285.                           gPath[1] = [x1, y1]
  286.                           return 0
  287.                         end if
  288.                       end if
  289.                     end if
  290.                   end if
  291.                 end if
  292.               end if
  293.             end if
  294.           end if
  295.         end if
  296.       end if
  297.     end if
  298.     curY = nextY
  299.     curX = nextX
  300.     curNode = [curX, curY]
  301.     append(gPath, curNode)
  302.     if (curX = x2) and (curY = y2) then
  303.       found = 1
  304.       return 1
  305.     end if
  306.     if count(gPath) > 200 then
  307.       gPath = [0]
  308.       gPath[1] = [x1, y1]
  309.     end if
  310.   end repeat
  311. end
  312.  
  313. on checkIfNodeThere theNode
  314.   there = 0
  315.   repeat with counter = 1 to count(gPath)
  316.     if gPath[counter] = theNode then
  317.       there = 1
  318.     end if
  319.   end repeat
  320.   return there
  321. end
  322.  
  323. on getNextSprite
  324.   gPlayer1.setAntDeSelected()
  325.   gPlayer2.setAntDeSelected()
  326.   gPlayer3.setAntDeSelected()
  327.   gSelectedSprite = gSelectedSprite + 1
  328.   if gSelectedSprite > 52 then
  329.     gSelectedSprite = 50
  330.   end if
  331.   case gSelectedSprite of
  332.     50:
  333.       if gPlayer1.pState = 3 then
  334.         getNextSprite()
  335.         exit
  336.       end if
  337.     51:
  338.       if gPlayer2.pState = 3 then
  339.         getNextSprite()
  340.         exit
  341.       end if
  342.     52:
  343.       if gPlayer3.pState = 3 then
  344.         getNextSprite()
  345.         exit
  346.       end if
  347.   end case
  348.   case gSelectedSprite of
  349.     50:
  350.       gPlayer1.setAntSelected()
  351.     51:
  352.       gPlayer2.setAntSelected()
  353.     52:
  354.       gPlayer3.setAntSelected()
  355.     otherwise:
  356.       sprite(16).blend = 0
  357.       gSelectedSprite = 0
  358.   end case
  359.   sprite(16).loc = sprite(gSelectedSprite).loc
  360. end
  361.