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

  1. property pSpaceStart, pSpace, pEnter, pConfusing, pEnterStart, pEneTimeStart, pEneTimeStart2, pSeed, pGettingSickOfUsingTimersForEverything
  2. global gCurrentLevel, gSelectedSprite, gBombList, gPlayer1, gPlayer2, gPlayer3, gEnemy1, gEnemy2, gEnemy3, gPath, gInfluence, gTotalHealth, gTotalScore
  3.  
  4. on new
  5.   pGettingSickOfUsingTimersForEverything = the ticks
  6.   pEneTimeStart = the ticks
  7.   pEneTimeStart2 = the ticks
  8.   pSpace = 0
  9.   pConfusing = 0
  10.   gBombList = []
  11.   gSelectedSprite = 0
  12.   sprite(16).blend = 0
  13.   gCurrentLevel = gCurrentLevel + 1
  14.   newLevel(gCurrentLevel)
  15.   gPlayer1 = new(script("AntScript"), 1, 2, 3, 20, 410, "sprite1", 50)
  16.   gPlayer2 = new(script("AntScript"), 1, 2, 3, 60, 410, "sprite1", 51)
  17.   gPlayer3 = new(script("AntScript"), 1, 2, 3, 140, 410, "sprite1", 52)
  18.   gEnemy1 = new(script("AntScript"), 1, 2, 3, 250, 50, "sprite2", 54)
  19.   gEnemy2 = new(script("AntScript"), 1, 2, 3, 320, 30, "sprite2", 55)
  20.   gEnemy3 = new(script("AntScript"), 1, 2, 3, 180, 50, "sprite2", 56)
  21.   gSelectedSprite = 52
  22.   gPlayer3.setAntSelected()
  23.   pathFind(gPlayer3.getAntPositionX() / 22, gPlayer3.getAntPositionY() / 22, 10, 16)
  24.   gPlayer3.setDaPath(gPath)
  25.   aTimer = the ticks
  26.   counter = 0
  27.   repeat while counter < 50
  28.     if (aTimer + 1) < the ticks then
  29.       counter = counter + 1
  30.       aTimer = the ticks
  31.       gPlayer3.updateAnt()
  32.       updateStage()
  33.     end if
  34.   end repeat
  35.   doTitle()
  36. end
  37.  
  38. on exitFrame me
  39.   doInput()
  40.   repeat with counter = 1 to count(gBombList)
  41.     gBombList[counter].updateBomb()
  42.   end repeat
  43.   gEnemy1.updateAnt()
  44.   gEnemy2.updateAnt()
  45.   gEnemy3.updateAnt()
  46.   doEnemyIntelligence()
  47.   go(the frame)
  48. end
  49.  
  50. on doInput
  51.   if (keyPressed(RETURN) = 1) and (pConfusing = 0) then
  52.     getNextSprite()
  53.     pConfusing = 1
  54.   end if
  55.   if (keyPressed(RETURN) = 0) and (pConfusing = 1) then
  56.     pConfusing = 0
  57.   end if
  58.   if keyPressed(126) and keyPressed(123) then
  59.     case gSelectedSprite of
  60.       50:
  61.         gPlayer1.setAntDirection(8)
  62.         gPlayer1.moveAnt()
  63.       51:
  64.         gPlayer2.setAntDirection(8)
  65.         gPlayer2.moveAnt()
  66.       52:
  67.         gPlayer3.setAntDirection(8)
  68.         gPlayer3.moveAnt()
  69.     end case
  70.   else
  71.     if keyPressed(126) and keyPressed(124) then
  72.       case gSelectedSprite of
  73.         50:
  74.           gPlayer1.setAntDirection(2)
  75.           gPlayer1.moveAnt()
  76.         51:
  77.           gPlayer2.setAntDirection(2)
  78.           gPlayer2.moveAnt()
  79.         52:
  80.           gPlayer3.setAntDirection(2)
  81.           gPlayer3.moveAnt()
  82.       end case
  83.     else
  84.       if keyPressed(125) and keyPressed(123) then
  85.         case gSelectedSprite of
  86.           50:
  87.             gPlayer1.setAntDirection(6)
  88.             gPlayer1.moveAnt()
  89.           51:
  90.             gPlayer2.setAntDirection(6)
  91.             gPlayer2.moveAnt()
  92.           52:
  93.             gPlayer3.setAntDirection(6)
  94.             gPlayer3.moveAnt()
  95.         end case
  96.       else
  97.         if keyPressed(125) and keyPressed(124) then
  98.           case gSelectedSprite of
  99.             50:
  100.               gPlayer1.setAntDirection(4)
  101.               gPlayer1.moveAnt()
  102.             51:
  103.               gPlayer2.setAntDirection(4)
  104.               gPlayer2.moveAnt()
  105.             52:
  106.               gPlayer3.setAntDirection(4)
  107.               gPlayer3.moveAnt()
  108.           end case
  109.         else
  110.           if keyPressed(123) then
  111.             case gSelectedSprite of
  112.               50:
  113.                 gPlayer1.setAntDirection(7)
  114.                 gPlayer1.moveAnt()
  115.               51:
  116.                 gPlayer2.setAntDirection(7)
  117.                 gPlayer2.moveAnt()
  118.               52:
  119.                 gPlayer3.setAntDirection(7)
  120.                 gPlayer3.moveAnt()
  121.             end case
  122.           else
  123.             if keyPressed(124) then
  124.               case gSelectedSprite of
  125.                 50:
  126.                   gPlayer1.setAntDirection(3)
  127.                   gPlayer1.moveAnt()
  128.                 51:
  129.                   gPlayer2.setAntDirection(3)
  130.                   gPlayer2.moveAnt()
  131.                 52:
  132.                   gPlayer3.setAntDirection(3)
  133.                   gPlayer3.moveAnt()
  134.               end case
  135.             else
  136.               if keyPressed(126) then
  137.                 case gSelectedSprite of
  138.                   50:
  139.                     gPlayer1.setAntDirection(1)
  140.                     gPlayer1.moveAnt()
  141.                   51:
  142.                     gPlayer2.setAntDirection(1)
  143.                     gPlayer2.moveAnt()
  144.                   52:
  145.                     gPlayer3.setAntDirection(1)
  146.                     gPlayer3.moveAnt()
  147.                 end case
  148.               else
  149.                 if keyPressed(125) then
  150.                   case gSelectedSprite of
  151.                     50:
  152.                       gPlayer1.setAntDirection(5)
  153.                       gPlayer1.moveAnt()
  154.                     51:
  155.                       gPlayer2.setAntDirection(5)
  156.                       gPlayer2.moveAnt()
  157.                     52:
  158.                       gPlayer3.setAntDirection(5)
  159.                       gPlayer3.moveAnt()
  160.                   end case
  161.                 end if
  162.               end if
  163.             end if
  164.           end if
  165.         end if
  166.       end if
  167.     end if
  168.   end if
  169.   if (the mouseDown = 1) and (pSpace = 0) and ((pGettingSickOfUsingTimersForEverything + 20) < the ticks) then
  170.     pGettingSickOfUsingTimersForEverything = the ticks
  171.     pSpace = 1
  172.     pSpaceStart = the ticks
  173.     case gSelectedSprite of
  174.       50:
  175.         gPlayer1.setReadyTaLaunch()
  176.       51:
  177.         gPlayer2.setReadyTaLaunch()
  178.       52:
  179.         gPlayer3.setReadyTaLaunch()
  180.     end case
  181.   end if
  182.   if the mouseDown = 1 then
  183.     holdTime = (the ticks - pSpaceStart) / 3
  184.     if holdTime > 15 then
  185.       holdTime = 15
  186.     end if
  187.     sprite(12).width = holdTime * 121 / 15
  188.   end if
  189.   if (the mouseDown = 0) and (pSpace = 1) then
  190.     sprite(12).width = 2
  191.     if not (gSelectedSprite = 0) then
  192.       pSpace = 0
  193.       holdTime = (the ticks - pSpaceStart) / 3
  194.       if holdTime > 15 then
  195.         holdTime = 15
  196.       end if
  197.       if holdTime < 4 then
  198.         holdTime = 4
  199.       end if
  200.       case gSelectedSprite of
  201.         50:
  202.           gPlayer1.startBombThrow(1, holdTime * 20)
  203.         51:
  204.           gPlayer2.startBombThrow(1, holdTime * 20)
  205.         52:
  206.           gPlayer3.startBombThrow(1, holdTime * 20)
  207.       end case
  208.     end if
  209.   end if
  210.   if (the rightMouseDown = 1) and (pEnter = 0) and ((pGettingSickOfUsingTimersForEverything + 20) < the ticks) then
  211.     pGettingSickOfUsingTimersForEverything = the ticks
  212.     pEnter = 1
  213.     pEnterStart = the ticks
  214.     case gSelectedSprite of
  215.       50:
  216.         gPlayer1.setReadyTaLaunch()
  217.       51:
  218.         gPlayer2.setReadyTaLaunch()
  219.       52:
  220.         gPlayer3.setReadyTaLaunch()
  221.     end case
  222.   end if
  223.   if the rightMouseDown = 1 then
  224.     holdTime = (the ticks - pEnterStart) / 3
  225.     if holdTime > 15 then
  226.       holdTime = 15
  227.     end if
  228.     sprite(12).width = holdTime * 121 / 15
  229.   end if
  230.   if (the rightMouseDown = 0) and (pEnter = 1) then
  231.     sprite(12).width = 2
  232.     if not (gSelectedSprite = 0) then
  233.       pEnter = 0
  234.       holdTime = (the ticks - pEnterStart) / 3
  235.       if holdTime > 15 then
  236.         holdTime = 15
  237.       end if
  238.       if holdTime < 4 then
  239.         holdTime = 4
  240.       end if
  241.       case gSelectedSprite of
  242.         50:
  243.           gPlayer1.startBombThrow(2, holdTime * 20)
  244.         51:
  245.           gPlayer2.startBombThrow(2, holdTime * 20)
  246.         52:
  247.           gPlayer3.startBombThrow(2, holdTime * 20)
  248.       end case
  249.     end if
  250.   end if
  251. end
  252.  
  253. on newLevel theLevel
  254.   gTotalHealth = 150
  255.   member("HealthDisplay").text = string(gTotalHealth)
  256.   member("Alpha1").image = member("Alpha1Copy").image
  257.   member("FortAlpha").image = member("FortAlphaCopy").image
  258.   case theLevel of
  259.     1:
  260.       sprite(7).member = "Alpha1"
  261.       sprite(5).member = "Background1"
  262.       pSeed = 3
  263.       sprite(281).visible = 0
  264.       sprite(282).visible = 0
  265.     2:
  266.       pSeed = 2
  267.       sprite(7).member = "Alpha1"
  268.       sprite(5).member = "Background1"
  269.       sprite(281).visible = 0
  270.       sprite(282).visible = 0
  271.     3:
  272.       pSeed = 1
  273.       sprite(7).member = "Alpha1"
  274.       sprite(5).member = "Background1"
  275.       sprite(281).visible = 0
  276.       sprite(282).visible = 0
  277.     4:
  278.       sprite(7).member = "Alpha1"
  279.       sprite(5).member = "Background1"
  280.       sprite(281).visible = 0
  281.       sprite(282).visible = 0
  282.   end case
  283. end
  284.  
  285. on doEnemyIntelligence
  286.   if (gPlayer1.pState = 3) and (gPlayer2.pState = 3) and (gPlayer3.pState = 3) then
  287.     exit
  288.   end if
  289.   if (pEneTimeStart2 + 10) < the ticks then
  290.     pEneTimeStart2 = the ticks
  291.     allHiding = 1
  292.     if not ((gPlayer1.pPositionX < 115) and (gPlayer1.pPositionY > 395)) and not (gPlayer1.pState = 3) then
  293.       allHiding = 0
  294.     else
  295.       if not ((gPlayer2.pPositionX < 115) and (gPlayer2.pPositionY > 395)) and not (gPlayer2.pState = 3) then
  296.         allHiding = 0
  297.       else
  298.         if not ((gPlayer3.pPositionX < 115) and (gPlayer3.pPositionY > 395)) and not (gPlayer3.pState = 3) then
  299.           allHiding = 0
  300.         end if
  301.       end if
  302.     end if
  303.     if not (gEnemy1.pState = 3) and (random(pSeed) = 1) then
  304.       curX = gEnemy1.pPositionX
  305.       curY = gEnemy1.pPositionY
  306.       if gPlayer1.pState = 3 then
  307.         distance1 = 1200
  308.       else
  309.         if (allHiding = 0) and ((gPlayer1.pPositionX < 115) and (gPlayer1.pPositionY > 395)) then
  310.           distance1 = 1200
  311.         else
  312.           distance1 = sqrt(((gPlayer1.pPositionX - curX) * (gPlayer1.pPositionX - curX)) + ((gPlayer1.pPositionY - curY) * (gPlayer1.pPositionY - curY)))
  313.         end if
  314.       end if
  315.       if gPlayer2.pState = 3 then
  316.         distance2 = 1200
  317.       else
  318.         if (allHiding = 0) and ((gPlayer2.pPositionX < 115) and (gPlayer2.pPositionY > 395)) then
  319.           distance2 = 1200
  320.         else
  321.           distance2 = sqrt(((gPlayer2.pPositionX - curX) * (gPlayer2.pPositionX - curX)) + ((gPlayer2.pPositionY - curY) * (gPlayer2.pPositionY - curY)))
  322.         end if
  323.       end if
  324.       if gPlayer3.pState = 3 then
  325.         distance3 = 1200
  326.       else
  327.         if (allHiding = 0) and ((gPlayer3.pPositionX < 115) and (gPlayer3.pPositionY > 395)) then
  328.           distance3 = 1200
  329.         else
  330.           distance3 = sqrt(((gPlayer3.pPositionX - curX) * (gPlayer3.pPositionX - curX)) + ((gPlayer3.pPositionY - curY) * (gPlayer3.pPositionY - curY)))
  331.         end if
  332.       end if
  333.       if (distance1 < distance2) and (distance1 < distance3) and (distance1 < 300) then
  334.         gEnemy1.EnemyShot(gPlayer1.pPositionX, gPlayer1.pPositionY, distance1)
  335.       else
  336.         if (distance2 < distance1) and (distance2 < distance3) and (distance2 < 300) then
  337.           gEnemy1.EnemyShot(gPlayer2.pPositionX, gPlayer2.pPositionY, distance2)
  338.         else
  339.           if distance3 < 300 then
  340.             gEnemy1.EnemyShot(gPlayer3.pPositionX, gPlayer3.pPositionY, distance3)
  341.           end if
  342.         end if
  343.       end if
  344.     end if
  345.     if not (gEnemy2.pState = 3) and (random(pSeed) = 1) then
  346.       curX = gEnemy2.pPositionX
  347.       curY = gEnemy2.pPositionY
  348.       if gPlayer1.pState = 3 then
  349.         distance1 = 1200
  350.       else
  351.         if (allHiding = 0) and ((gPlayer1.pPositionX < 115) and (gPlayer1.pPositionY > 395)) then
  352.           distance1 = 1200
  353.         else
  354.           distance1 = sqrt(((gPlayer1.pPositionX - curX) * (gPlayer1.pPositionX - curX)) + ((gPlayer1.pPositionY - curY) * (gPlayer1.pPositionY - curY)))
  355.         end if
  356.       end if
  357.       if gPlayer2.pState = 3 then
  358.         distance2 = 1200
  359.       else
  360.         if (allHiding = 0) and ((gPlayer2.pPositionX < 115) and (gPlayer2.pPositionY > 395)) then
  361.           distance2 = 1200
  362.         else
  363.           distance2 = sqrt(((gPlayer2.pPositionX - curX) * (gPlayer2.pPositionX - curX)) + ((gPlayer2.pPositionY - curY) * (gPlayer2.pPositionY - curY)))
  364.         end if
  365.       end if
  366.       if gPlayer3.pState = 3 then
  367.         distance3 = 1200
  368.       else
  369.         if (allHiding = 0) and ((gPlayer3.pPositionX < 115) and (gPlayer3.pPositionY > 395)) then
  370.           distance3 = 1200
  371.         else
  372.           distance3 = sqrt(((gPlayer3.pPositionX - curX) * (gPlayer3.pPositionX - curX)) + ((gPlayer3.pPositionY - curY) * (gPlayer3.pPositionY - curY)))
  373.         end if
  374.       end if
  375.       if (distance1 < distance2) and (distance1 < distance3) and (distance1 < 300) then
  376.         gEnemy2.EnemyShot(gPlayer1.pPositionX, gPlayer1.pPositionY, distance1)
  377.       else
  378.         if (distance2 < distance1) and (distance2 < distance3) and (distance2 < 300) then
  379.           gEnemy2.EnemyShot(gPlayer2.pPositionX, gPlayer2.pPositionY, distance2)
  380.         else
  381.           if distance3 < 300 then
  382.             gEnemy2.EnemyShot(gPlayer3.pPositionX, gPlayer3.pPositionY, distance3)
  383.           end if
  384.         end if
  385.       end if
  386.     end if
  387.     if not (gEnemy3.pState = 3) and (random(pSeed) = 1) then
  388.       curX = gEnemy3.pPositionX
  389.       curY = gEnemy3.pPositionY
  390.       if gPlayer1.pState = 3 then
  391.         distance1 = 1200
  392.       else
  393.         distance1 = sqrt(((gPlayer1.pPositionX - curX) * (gPlayer1.pPositionX - curX)) + ((gPlayer1.pPositionY - curY) * (gPlayer1.pPositionY - curY)))
  394.       end if
  395.       if gPlayer2.pState = 3 then
  396.         distance2 = 1200
  397.       else
  398.         distance2 = sqrt(((gPlayer2.pPositionX - curX) * (gPlayer2.pPositionX - curX)) + ((gPlayer2.pPositionY - curY) * (gPlayer2.pPositionY - curY)))
  399.       end if
  400.       if gPlayer3.pState = 3 then
  401.         distance3 = 1200
  402.       else
  403.         distance3 = sqrt(((gPlayer3.pPositionX - curX) * (gPlayer3.pPositionX - curX)) + ((gPlayer3.pPositionY - curY) * (gPlayer3.pPositionY - curY)))
  404.       end if
  405.       if (distance1 < distance2) and (distance1 < distance3) and (distance1 < 300) then
  406.         gEnemy3.EnemyShot(gPlayer1.pPositionX, gPlayer1.pPositionY, distance1)
  407.       else
  408.         if (distance2 < distance1) and (distance2 < distance3) and (distance2 < 300) then
  409.           gEnemy3.EnemyShot(gPlayer2.pPositionX, gPlayer2.pPositionY, distance2)
  410.         else
  411.           if distance3 < 300 then
  412.             gEnemy3.EnemyShot(gPlayer3.pPositionX, gPlayer3.pPositionY, distance3)
  413.           end if
  414.         end if
  415.       end if
  416.     end if
  417.   end if
  418.   if (pEneTimeStart + 120) < the ticks then
  419.     pEneTimeStart = the ticks
  420.     if not (gEnemy1.pState = 3) then
  421.       if gEnemy1.pPray = 0 then
  422.         found = 0
  423.         repeat while found = 0
  424.           thePray = random(3)
  425.           case thePray of
  426.             1:
  427.               if not (gPlayer1.pState = 3) then
  428.                 gEnemy1.pPray = 1
  429.                 found = 1
  430.               end if
  431.             2:
  432.               if not (gPlayer2.pState = 3) then
  433.                 gEnemy1.pPray = 2
  434.                 found = 1
  435.               end if
  436.             3:
  437.               if not (gPlayer3.pState = 3) then
  438.                 gEnemy1.pPray = 3
  439.                 found = 1
  440.               end if
  441.           end case
  442.         end repeat
  443.       end if
  444.       case gEnemy1.pPray of
  445.         1:
  446.           if gPlayer1.pState = 3 then
  447.             gEnemy1.pPray = 0
  448.           end if
  449.         2:
  450.           if gPlayer2.pState = 3 then
  451.             gEnemy1.pPray = 0
  452.           end if
  453.         3:
  454.           if gPlayer3.pState = 3 then
  455.             gEnemy1.pPray = 0
  456.           end if
  457.       end case
  458.       findNewPos(gEnemy1.pPositionX, gEnemy1.pPositionY, gEnemy1.pPray, 1)
  459.     end if
  460.     if not (gEnemy2.pState = 3) then
  461.       if gEnemy2.pPray = 0 then
  462.         found = 0
  463.         repeat while found = 0
  464.           thePray = random(3)
  465.           case thePray of
  466.             1:
  467.               if not (gPlayer1.pState = 3) then
  468.                 gEnemy2.pPray = 1
  469.                 found = 1
  470.               end if
  471.             2:
  472.               if not (gPlayer2.pState = 3) then
  473.                 gEnemy2.pPray = 2
  474.                 found = 1
  475.               end if
  476.             3:
  477.               if not (gPlayer3.pState = 3) then
  478.                 gEnemy2.pPray = 3
  479.                 found = 1
  480.               end if
  481.           end case
  482.         end repeat
  483.       end if
  484.       case gEnemy2.pPray of
  485.         1:
  486.           if gPlayer1.pState = 3 then
  487.             gEnemy2.pPray = 0
  488.           end if
  489.         2:
  490.           if gPlayer2.pState = 3 then
  491.             gEnemy2.pPray = 0
  492.           end if
  493.         3:
  494.           if gPlayer3.pState = 3 then
  495.             gEnemy2.pPray = 0
  496.           end if
  497.       end case
  498.       findNewPos(gEnemy2.pPositionX, gEnemy2.pPositionY, gEnemy2.pPray, 2)
  499.     end if
  500.   end if
  501. end
  502.  
  503. on findNewPos curX, curY, thePray, refToEnemy
  504.   case thePray of
  505.     1:
  506.       aX = gPlayer1.pPositionX
  507.       aY = gPlayer1.pPositionY
  508.     2:
  509.       aX = gPlayer2.pPositionX
  510.       aY = gPlayer2.pPositionY
  511.     3:
  512.       aX = gPlayer3.pPositionX
  513.       aY = gPlayer3.pPositionY
  514.   end case
  515.   theDistance = sqrt(((aX - curX) * (aX - curX)) + ((aY - curY) * (aY - curY)))
  516.   if (theDistance <= 200) and (theDistance >= 80) then
  517.     exit
  518.   end if
  519.   found = 0
  520.   fcounter = 0
  521.   repeat while found = 0
  522.     fcounter = fcounter + 1
  523.     if fcounter > 10 then
  524.       exit repeat
  525.     end if
  526.     curX = random(420)
  527.     curY = random(420)
  528.     theDistance = sqrt(((aX - curX) * (aX - curX)) + ((aY - curY) * (aY - curY)))
  529.     if (theDistance <= 200) and (theDistance >= 80) then
  530.       found = 1
  531.       case refToEnemy of
  532.         1:
  533.           pathFind(gEnemy1.getAntPositionX() / 22, gEnemy1.getAntPositionY() / 22, curX / 22, curY / 22)
  534.           gEnemy1.setDaPath(gPath)
  535.         2:
  536.           pathFind(gEnemy2.getAntPositionX() / 22, gEnemy2.getAntPositionY() / 22, curX / 22, curY / 22)
  537.           gEnemy2.setDaPath(gPath)
  538.         3:
  539.           pathFind(gEnemy3.getAntPositionX() / 22, gEnemy3.getAntPositionY() / 22, curX / 22, curY / 22)
  540.           gEnemy3.setDaPath(gPath)
  541.       end case
  542.     end if
  543.   end repeat
  544. end
  545.  
  546. on doTitle
  547.   sprite(285).puppet = 1
  548.   sprite(285).member = "title10"
  549.   sprite(285).loc = point(290, 220)
  550.   sprite(285).blend = 0
  551.   aTimer = the ticks
  552.   repeat while sprite(285).blend <= 80
  553.     if (aTimer + 2) < the ticks then
  554.       aTimer = the ticks
  555.       sprite(285).blend = sprite(285).blend + 20
  556.       updateStage()
  557.     end if
  558.   end repeat
  559.   sprite(285).blend = 100
  560.   aTimer = the ticks
  561.   repeat while (aTimer + 60) > the ticks
  562.   end repeat
  563.   aTimer = the ticks
  564.   repeat while sprite(285).blend >= 20
  565.     if (aTimer + 2) < the ticks then
  566.       aTimer = the ticks
  567.       sprite(285).blend = sprite(285).blend - 20
  568.       updateStage()
  569.     end if
  570.   end repeat
  571.   sprite(285).blend = 0
  572.   sprite(285).puppet = 0
  573. end
  574.