Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stop();
  2.  
  3. var song:Sound = new Sound();
  4. song.attachSound("song.wav");
  5. fort.swapDepths(1002100);
  6. s1.swapDepths(1003125);
  7. s2.swapDepths(1003134);
  8. s3.swapDepths(1003334);
  9.  
  10. song.start(0,99);
  11. song.start(0,99);
  12.  
  13. var akshot:Sound = new Sound();
  14. akshot.attachSound("ak.wav");
  15.  
  16. var damage:Sound = new Sound();
  17. damage.attachSound("damage.wav");
  18.  
  19. var pCol:Sound = new Sound();
  20. pCol.attachSound("pCol.wav");
  21.  
  22. akshot.setVolume(20);
  23.  
  24. import flash.filters.BlurFilter;
  25. import mx.transitions.Tween;
  26. import mx.transitions.easing.Strong;
  27.  
  28. var totalBlur:Number = 8;
  29. var noBlur :Number = 0;
  30.  
  31. keyListener = new Object();
  32. sBlur = 0;
  33. keyListener.onKeyDown = function() {
  34.   num = Key.getAscii();
  35.   if(num == 112 || num == 32){
  36.       gamePause = !gamePause;
  37.       if(sBlur == 0){
  38.         sBlur = 1;
  39.       }else{
  40.         sBlur = 0;
  41.       }
  42.   }
  43. }
  44. Key.addListener(keyListener);
  45.  
  46. depth = 10;
  47. speed = 2;
  48.  
  49. jumping = 0;
  50. ducking = 0;
  51. falling = 0;
  52. touchingGround = 0;
  53. rightWall = 0;
  54. leftWall = 0;
  55. right = 1;
  56. MouseDown = 0;
  57. delay = 0;
  58. enemyAttach = 0;
  59. ySpeed = 0;
  60. shake = 0;
  61. score = 0;
  62. kills = 0;
  63. wave = 1;
  64. ammo = new Array(200, 0, 0, 0, 0);
  65. gunUsed = 0;
  66. money = 0;
  67. health = 100;
  68.  
  69. bullets = new Array();
  70. bulletX = new Array();
  71. bulletY = new Array();
  72.  
  73. enemies = new Array();
  74. enemyLives = new Array();
  75.  
  76. fallingSpeedA = new Array();
  77. delayA = new Array();
  78. shootingA = new Array(); // Equivalent to MouseDown for player.
  79. leftWall_a = new Array();
  80. rightWall_a = new Array();
  81. rightA = new Array();
  82. touchingGroundA = new Array();
  83. fallingA = new Array();
  84. duckingA = new Array();
  85. jumpingA = new Array();
  86. rightSpeed = new Array();
  87. leftSpeed = new Array();
  88. enemyType = new Array();
  89.  
  90. xSpeed = 0;
  91. ySpeed = 0;
  92. friction2 = .85;
  93.  
  94. gravity = .8;
  95. engravity = .5;
  96. friction = .99;
  97.  
  98. attachMovie("pBottom","player", 1000000);
  99. player._x = Stage.width/2;
  100. player._y = (Stage.height/2) + (Stage.height/6);
  101.  
  102. function updateStats(){
  103.     s3.scoreTxt = score;
  104.     s3.killsTxt = kills;
  105.     s3.levelTxt = wave;
  106.     s3.ammoTxt = ammo[gunUsed];
  107.     s3.moneyTxt = money;
  108.     s2._xscale = health;
  109.     s3.hTxt = health + "/100";
  110. }
  111. updateStats();
  112. attachMovie("player_top","player_top", 1000001);
  113. player_top._x = Stage.width/2;
  114. player_top._y = (Stage.height/2) + (Stage.height/6);;
  115. toMove = 0;
  116. gamePause = false;
  117.  
  118. pScale = 75;
  119. player._xscale = player._yscale = 75;
  120. player_top._xscale = player_top._yscale = 75;
  121. function onEnterFrame(){
  122.     if(sBlur == 1){
  123.         var blur:BlurFilter = new BlurFilter(totalBlur, totalBlur, 3);
  124.         _root.filters = new Array(blur);
  125.         var blurTween:Tween;
  126.         blurTween = new Tween(blur, "blurX", Strong.easeOut, blur.blurX, noBlur, 1.0, true);
  127.         blurTween.onMotionChanged = function() {
  128.             blur.blurY = blur.blurX;
  129.             _root.filters = new Array(blur);
  130.         }  
  131.     }
  132.     if(sBlur == 0){
  133.         _root.filters = null;
  134.     }
  135.     if(!gamePause){
  136.     if(_xmouse > player._x){
  137.         right = 1;
  138.     }
  139.     player_top.gun.gun._x = player_top.gun.aa._x;
  140.     player_top.gun.gun._y = player_top.gun.aa._y;
  141.     if((Key.isDown(Key.RIGHT) || Key.isDown(68)) && rightWall == 0 && ducking != 1){
  142.         xSpeed += speed;
  143.         if(level.ground.hitTest(player._x, player._y + 50, true)){
  144.             player.gotoAndStop(2);
  145.             player_top.gotoAndStop(3);
  146.         }else{
  147.             player_top.gotoAndPlay(7);
  148.         }
  149.         player._xscale = pScale;
  150.     }
  151.     else if((Key.isDown(Key.LEFT) || Key.isDown(65)) && leftWall == 0 && ducking != 1){
  152.         xSpeed -= speed;
  153.         if(level.ground.hitTest(player._x, player._y + 50, true)){
  154.             player.gotoAndStop(2);
  155.             player_top.gotoAndStop(4);
  156.         }
  157.         else{
  158.             player_top.gotoAndStop(8);
  159.         }
  160.         player._xscale = -pScale;
  161.     }else{
  162.         if(Key.isDown(Key.DOWN) || Key.isDown(83) || !level.ground.hitTest(player._x, player._y + 50, true)){
  163.         }else{
  164.             if(player._xscale == pScale){
  165.                 player_top.gotoAndStop(1);
  166.             }else{
  167.                 player_top.gotoAndStop(2);
  168.             }
  169.             player.gotoAndStop(1);
  170.         }
  171.     }
  172.     //player_top.gun._y = -18;
  173.     if((Key.isDown(Key.DOWN) || Key.isDown(83)) && level.ground.hitTest(player._x, player._y + 50, true)){
  174.         if(player._xscale == pScale){
  175.             player_top.gotoAndStop(5);
  176.             player.gotoAndStop(3);
  177.         }else{
  178.             player_top.gotoAndStop(6);
  179.             player.gotoAndStop(3);
  180.         }
  181.         //player_top.gun._y = 0;
  182.     }
  183.     xSpeed *= friction2;
  184.     //player._x += xSpeed;
  185.     level._x -= xSpeed;
  186.     fort._x -= xSpeed;
  187.     wall2._x -= xSpeed;
  188.     ducking = 0;
  189.     if((Key.isDown(Key.DOWN) || Key.isDown(83))){
  190.         ducking = 1;
  191.     }
  192.     if(level.ground.hitTest(player._x, player._y + (45) - 6, true)){
  193.         touchingGround = 1;
  194.         ySpeed = 0;
  195.         falling = 0;
  196.     }else{
  197.         touchingGround = 0;
  198.         falling = 1;
  199.     }
  200.    
  201.     if(falling == 1){
  202.         ySpeed += gravity;
  203.         ySpeed *= friction;
  204.     }
  205.    
  206.     if(jumping == 1){
  207.         ySpeed = - 15;
  208.         jumping = 0;
  209.     }
  210.    
  211.     //player._y += ySpeed;
  212.     level._y -= ySpeed;
  213.     fort._y -= ySpeed;
  214.     wall2._y -= ySpeed;
  215.     if((Key.isDown(Key.UP) || Key.isDown(87)) && falling == 0){
  216.         touchingGround = 0;
  217.         jumping = 1;
  218.     }
  219.     if(!level.ground.hitTest(player._x, player._y + 50, true)){
  220.         player.gotoAndStop(4);
  221.         if(player._xscale == pScale){
  222.             player_top.gotoAndStop(7);
  223.         }else{
  224.             player_top.gotoAndStop(8);
  225.         }
  226.     }
  227.     if(jumping == 1 && touchingGround == 1){
  228.         jumping = 0;
  229.     }
  230.     var playPlace = player._y;
  231.     while(level.ground.hitTest(player._x, player._y + (45) - 7, true)){
  232.         player._y -= .1; // Murked
  233.     }
  234.     toMove = player._y - (playPlace);
  235.     player._y = playPlace;
  236.     level._y -= toMove;
  237.     fort._y -= toMove;
  238.     wall2._y -= toMove;
  239.     for(i = pUps.length - 1; i >= 0; i--){
  240.         pUps[i]._y += toMove;
  241.     }
  242.     for(i = enemies.length - 1; i >= 0; i--){
  243.         enemies[i]._y -= toMove;
  244.     }
  245.     for(i = bullets.length - 1; i >= 0; i--){
  246.         bullets[i]._y -= toMove;
  247.     }
  248.     for(i = deadEnemies.length -1; i >= 0; i--){
  249.         deadEnemies[i]._y -= toMove;
  250.     }
  251.     var playPlace2 = player._x;
  252.     while(wall2.hitTest(player._x + (player._width/2), player._y, true)){
  253.         player._x -= 1; // Murked
  254.         wall2.t1.gotoAndPlay(2);
  255.         wall2.t2.gotoAndPlay(2);
  256.     }
  257.     while(wall2.hitTest(player._x - (player._width/2), player._y, true)){
  258.         player._x += 1; // Murked
  259.         wall2.t1.gotoAndPlay(2);
  260.         wall2.t2.gotoAndPlay(2);
  261.     }
  262.    
  263.     toMove = player._x - (playPlace2);
  264.     player._x = playPlace2;
  265.     level._x -= toMove;
  266.     fort._x -= toMove;
  267.     wall2._x -= toMove;
  268.     for(i = pUps.length - 1; i >= 0; i--){
  269.         pUps[i]._x -= toMove;
  270.     }
  271.     for(i = enemies.length - 1; i >= 0; i--){
  272.         enemies[i]._x -= toMove;
  273.     }
  274.     for(i = bullets.length - 1; i >= 0; i--){
  275.         bullets[i]._x -= toMove;
  276.     }
  277.     for(i = deadEnemies.length -1; i >= 0; i--){
  278.         deadEnemies[i]._x -= toMove;
  279.     }
  280.     //player._y = (Stage.height/2) + (Stage.height/4);
  281.     var xMouseDist = ((Stage.width/2) - _xmouse)/4;
  282.     var yMouseDist = ((Stage.height/2) + (Stage.height/6) - _ymouse)/4;
  283.     var distToGoX = (((Stage.width/2) + xMouseDist) - player._x)/4;
  284.     var distToGoY = (((Stage.height/2) + (Stage.height/6) + yMouseDist) - player._y)/4;
  285.     player._y += distToGoY;
  286.     level._y +=distToGoY;
  287.     fort._y += distToGoY;
  288.     wall2._x += distToGoX;
  289.     wall2._y += distToGoY;
  290.     player._x += distToGoX;
  291.     level._x +=distToGoX;
  292.     fort._x +=distToGoX;
  293.     for(i = pUps.length - 1; i >= 0; i--){
  294.         pUps[i]._x += distToGoX;
  295.         pUps[i]._y += distToGoY;
  296.     }
  297.     for(i = enemies.length - 1; i >= 0; i--){
  298.         enemies[i]._y += distToGoY;
  299.         enemies[i]._x += distToGoX;
  300.     }
  301.     for(i = bullets.length - 1; i >= 0; i--){
  302.         bullets[i]._y += distToGoY;
  303.         bullets[i]._x += distToGoX;
  304.     }
  305.     for(i = deadEnemies.length -1; i >= 0; i--){
  306.         deadEnemies[i]._x += distToGoX;
  307.         deadEnemies[i]._y += distToGoY;
  308.     }
  309.     player_top._x = player._x;
  310.     player_top._y = player._y;
  311.    
  312.     var dx:Number = _xmouse - (player_top._x + player_top.gun._x + player_top.gun.gun._x);
  313.     var dy:Number = _ymouse - (player_top._y + player_top.gun._y + player_top.gun.gun._y);
  314.     var radians:Number = Math.atan2(dy, dx);
  315.     player_top.gun.gun._rotation = radians * 180 / Math.PI;
  316.    
  317.     if(_xmouse < player_top._x){
  318.         player_top.gun.gun._xscale = 100;
  319.     }
  320.     if(_xmouse > player_top._x){
  321.         player_top.gun.gun._xscale = -100;
  322.     }
  323.     if(_xmouse >= player_top._x){
  324.         player_top.gun.gun._rotation += 180;
  325.     }
  326.     shooting();
  327.     enemyCreate();
  328.     enemyMovement();
  329.     bulletMovement();
  330.     shaker();
  331.     pMoves();
  332.     deadEnemiesMovement();
  333.     player_top.gun.gun._x = player_top.gun.aa._x;
  334.     player_top.gun.gun._y = player_top.gun.aa._y;
  335.     player_top.gun.gun._rotation -= 5;
  336.     if(_xmouse >= player._x){
  337.         player_top.gun.gun._rotation += 10;
  338.     }
  339.     player_top.gun.gotoAndStop(player.gun._currentframe);
  340.    
  341.     wall2._x = level._x + 525.15 + 95.7;
  342.     fort._x = level._x + 429.5;
  343.     wall2._y = level._y + 174.35 - 305.7;
  344.     fort._y = level._y - 80.45;
  345.     }
  346. }
  347.  
  348. onMouseDown = function(){
  349.     MouseDown = 1;
  350. }
  351. onMouseUp = function(){
  352.     MouseDown = 0;
  353. }
  354.  
  355. function shaker(){
  356.     if(shake == 0){
  357.     }
  358.     else if(shake == 1){
  359.         shake += 1;
  360.         _root._x += Math.cos(player_top.gun.gun._rotation*Math.PI/180)*5;
  361.         _root._y += Math.sin(player_top.gun.gun._rotation*Math.PI/180)*5;
  362.     }
  363.     else if(shake == 2){
  364.         shake = 3;
  365.         _root._x = Math.cos(player_top.gun.gun._rotation*Math.PI/180)*4;
  366.         _root._y = Math.sin(player_top.gun.gun._rotation*Math.PI/180)*4;
  367.     }
  368.     else if(shake == 3){
  369.         shake = 4;
  370.         _root._x = Math.cos(player_top.gun.gun._rotation*Math.PI/180)*3;
  371.         _root._y = Math.sin(player_top.gun.gun._rotation*Math.PI/180)*3;
  372.     }
  373.     else if(shake == 4){
  374.         shake = 0;
  375.         _root._x = 0;
  376.         _root._y = 0;
  377.     }
  378.     tt._x = 318.9 - _root._x;
  379.     tt._y = 288.65 - _root._y;
  380.     s1._x = 348 - _root._x;
  381.     s1._y = 9.5 - _root._y;
  382.     s2._x = 9.5 - _root._x;
  383.     s2._y = 9 - _root._y;
  384.     s3._x = 351.95 - _root._x;
  385.     s3._y = 25.2 - _root._y;
  386. }
  387. xmoveAdd = 0;
  388. ymoveAdd = 0;
  389. currentX = 0;
  390. currentY = 0;
  391. function shooting(){
  392.     delay -= 1;
  393.     if(MouseDown == 1 && delay <= 0){
  394.         if(shake == 0){
  395.             shake = 1;
  396.         }
  397.         ammo[gunUsed] -= 1;
  398.         updateStats();
  399.         akshot.start();
  400.         player_top.gun.gun.gShot.gotoAndStop(randRange(2,4));
  401.         bc = attachMovie("bCasing", "bCasing" + depth, depth);
  402.         depth++;
  403.        
  404.         if(_xmouse >= player._x){
  405.             player_top.gun.gun._rotation += 180;
  406.         }
  407.         xmoveAdd2 = (Math.cos(player_top.gun.gun._rotation * Math.PI / 180)*10);
  408.         ymoveAdd2 = (Math.sin(player_top.gun.gun._rotation * Math.PI / 180)*10);
  409.         currentX2 = player_top._x + (player_top.gun._x + (player_top.gun.gun._x)*(2.65))+(xmoveAdd2*3);
  410.         currentY2 = player_top._y + (player_top.gun._y + (player_top.gun.gun._y)*(2.65))+(ymoveAdd2*3);
  411.         bc._x = currentX2;
  412.         bc._y = currentY2;
  413.         if(_xmouse >= player._x){
  414.             player_top.gun.gun._rotation += 180;
  415.         }
  416.         var upLift = (Math.random()*5)+5;
  417.         var xDire = (Math.random()*4)-2;
  418.         var rotAng = Math.random()*10;
  419.         bc.onEnterFrame = function(){
  420.             upLift -= .7;
  421.             this._y -= upLift;
  422.             this._x += xDire;
  423.             this._alpha -= 2;
  424.             this._x -= xSpeed;
  425.             this._rotation += rotAng;
  426.             if(this._alpha <= 0){
  427.                 this.removeMovieClip();
  428.             }
  429.         }
  430.         delay = 5;
  431.         triangle.removeMovieClip();
  432.         createEmptyMovieClip ("triangle", 900555 + depth);
  433.         depth++;
  434.         with (triangle){
  435.             lineStyle(1, 0xFFFFFF);
  436.             if(_xmouse >= player_top._x){
  437.                 player_top.gun.gun._rotation += 180;
  438.             }
  439.             xmoveAdd = (Math.cos(player_top.gun.gun._rotation * Math.PI / 180)*10)+Math.random();
  440.             ymoveAdd = (Math.sin(player_top.gun.gun._rotation * Math.PI / 180)*10)+Math.random();
  441.             currentX = player_top._x + (player_top.gun._x + (player_top.gun.gun._x)*(2.65))+(xmoveAdd*7);
  442.             currentY = player_top._y + (player_top.gun._y + (player_top.gun.gun._y)*(2.65))+(ymoveAdd*7);
  443.             moveTo((player_top._x + (player_top.gun._x + (player_top.gun.gun._x)*(2.65)))+(xmoveAdd*7), (player_top._y + (player_top.gun._y + (player_top.gun.gun._y)*(2.65)))+(ymoveAdd*7));
  444.             for(t = 100; t>= 0; t--){
  445.                 currentX += xmoveAdd;
  446.                 currentY += ymoveAdd;
  447.                 lineTo(currentX, currentY);
  448.                 for(i = enemies.length - 1; i >= 0; i--){
  449.                     if(enemies[i].hitTest(currentX, currentY, true)){
  450.                         t = -5;
  451.                         enemyLives[i] -= 1;
  452.                         damage.start();
  453.                         damage.start();
  454.                         ep = _root.attachMovie("partExp", "partExt" + depth, depth);
  455.                         depth++;
  456.                         ep._x = currentX;
  457.                         ep._y = currentY;
  458.                         ep.gotoAndStop(randRange(1,3));
  459.                         ep._xscale = ep._yscale = 75;
  460.                         if(player._x - currentX >= 0){
  461.                             ep._xscale *= -1;
  462.                         }
  463.                         if(enemyLives[i] <= 0){
  464.                             si = _root.attachMovie("scoreInc", "scoreInc" + depth, depth);
  465.                             depth++;
  466.                             si._x = currentX;
  467.                             si._y = currentY;
  468.                             si.tNum.tNum = "+" + 10;
  469.                             deadEnemies.push(enemies[i]);
  470.                             removeEnemy(0);
  471.                         }
  472.                     }
  473.                 }
  474.                 if(level.ground.hitTest(currentX, currentY, true)){
  475.                     fs = _root.attachMovie("floorShot", "floor" + depth, depth);
  476.                     depth++;
  477.                     fs.gotoAndStop(randRange(1,3));
  478.                     currentX += xmoveAdd;
  479.                     currentY += ymoveAdd;
  480.                     lineTo(currentX, currentY);
  481.                     fs._x = currentX;
  482.                     fs._y = currentY;
  483.                     t = -5;
  484.                 }
  485.             }
  486.             if(_xmouse >= player_top._x){
  487.                 player_top.gun.gun._rotation -= 180;
  488.             }
  489.         }
  490.         player_top.gun.gun._rotation -= 2;
  491.         triangle.onEnterFrame = function(){
  492.             triangle._alpha -= triangle._alpha/4;
  493.             if(triangle._alpha <= 5){
  494.                 triangle.removeMovieClip();
  495.             }
  496.         }
  497.     }
  498. }
  499.  
  500. function bulletMovement(){
  501.     for(i = bullets.length; i >= 0; i--){
  502.         bullets[i]._x -= xSpeed;
  503.         bullets[i]._y -= ySpeed;
  504.         bullets[i]._x += bulletX[i];
  505.         bullets[i]._y += bulletY[i];
  506.        
  507.         if(level.ground.hitTest(bullets[i]._x,bullets[i]._y,true)){
  508.             bullets[i].removeMovieClip();
  509.             bullets.splice(i,1);
  510.             bulletX.splice(i,1);
  511.             bulletY.splice(i,1);
  512.         }
  513.         if(outside.hitTest(bullets[i]._x,bullets[i]._y,true)){
  514.             bullets[i].removeMovieClip();
  515.             bullets.splice(i,1);
  516.             bulletX.splice(i,1);
  517.             bulletY.splice(i,1);
  518.         }
  519.     }
  520. }
  521.  
  522. function enemyCreate(){
  523.     enemyAttach -= 1;
  524.     if(enemyAttach <= 0){
  525.         enemyAttach = 65;
  526.         var eType = randRange(1,3);
  527.         if(eType == 1){
  528.             en = attachMovie("enemy1","enemy" + depth,depth);
  529.             enemyLives.push(6);
  530.             rightSpeed.push(2);
  531.             leftSpeed.push(2);
  532.         }
  533.         if(eType == 2){
  534.             en = attachMovie("enemy2","enemy" + depth,depth);
  535.             enemyLives.push(2);
  536.             rightSpeed.push(5);
  537.             leftSpeed.push(5);
  538.         }
  539.         if(eType == 3){
  540.             en = attachMovie("enemy3","enemy" + depth,depth);
  541.             enemyLives.push(4);
  542.             rightSpeed.push(4);
  543.             leftSpeed.push(4);
  544.         }
  545.         depth++;
  546.         if(randRange(0,1) == 1){
  547.             en._x = -en._width/2;
  548.         }else{
  549.             en._x = Stage.width + (en._width/2);
  550.         }
  551.         if(wall2._x >= 1000){
  552.             en._x = Stage.width + (en._width/2);
  553.         }
  554.         if(wall2._x <= -300){
  555.             en._x = -en._width/2;
  556.         }
  557.         en._y = level._y + 50;
  558.         en._xscale = en._yscale = 75;
  559.         enemies.push(en);
  560.         enemyType.push(eType);
  561.         //Enemy vars
  562.         fallingSpeedA.push(0);
  563.         delayA.push(0);
  564.         shootingA.push(0);
  565.         leftWall_a.push(0);
  566.         rightWall_a.push(0);
  567.         rightA.push(1);
  568.         touchingGroundA.push(0);
  569.         fallingA.push(0);
  570.         duckingA.push(0);
  571.         jumpingA.push(0);
  572.        
  573.     }
  574. }
  575.  
  576. function enemyMovement(){
  577.     for(i = enemies.length - 1; i >= 0; i--){
  578.         enemies[i]._x -= xSpeed;
  579.         enemies[i]._y -= ySpeed;
  580.         if(player._x < enemies[i]._x && enemies[i]._currentframe != 2){
  581.             enemies[i]._x -= rightSpeed[i];
  582.             enemies[i]._xscale = 75;
  583.         }
  584.         if(player._x > enemies[i]._x && enemies[i]._currentframe != 2){
  585.             enemies[i]._x += leftSpeed[i];
  586.             enemies[i]._xscale = -75;
  587.         }
  588.         if(enemies[i]._currentframe == 2 && enemies[i].d1._currentframe == 5 && enemies[i].hitTest(player)){
  589.             health -= 10;
  590.             redD.gotoAndPlay(2);
  591.             if(health <= 0){
  592.                 health = 0;
  593.             }
  594.             updateStats();
  595.             if(enemyType[i] == 3){
  596.                 removeEnemy(1);
  597.             }
  598.         }
  599.         if(enemies[i].hitTest(player)){
  600.             enemies[i].gotoAndStop(2);
  601.             if(enemyType[i] == 2){
  602.                 deadEnemies.push(enemies[i]);
  603.                 removeEnemy(0);
  604.                 health -= 10;
  605.                 redD.gotoAndPlay(2);
  606.                 if(health <= 0){
  607.                     health = 0;
  608.                 }
  609.                 updateStats();
  610.             }
  611.         }
  612.        
  613.         if(level.ground.hitTest(enemies[i]._x, enemies[i]._y + (enemies[i]._height/2)  - 6, true)){
  614.         touchingGroundA[i] = 1;
  615.         fallingSpeedA[i] = 0;
  616.         fallingA[i] = 0;
  617.         }else{
  618.             touchingGroundA[i] = 0;
  619.             fallingA[i] = 1;
  620.         }
  621.    
  622.         if(fallingA[i] == 1){
  623.             fallingSpeedA[i] += engravity;
  624.             fallingSpeedA[i] *= friction;
  625.         }
  626.    
  627.         if(jumpingA[i] == 1){
  628.             fallingSpeedA[i] = - 15;
  629.             jumpingA[i] = 0;
  630.         }
  631.    
  632.         enemies[i]._y += fallingSpeedA[i];
  633.        
  634.         while(level.ground.hitTest(enemies[i]._x,enemies[i]._y - (enemies[i]._height/2), true)){
  635.             enemies[i]._y += 1;
  636.             fallingSpeedA[i] = 0;
  637.             }
  638.        
  639.        
  640.         if(jumpingA[i] == 1 && touchingGroundA[i] == 1){
  641.             jumpingA[i] = 0;
  642.         }
  643.    
  644.         if(level.ground.hitTest(enemies[i]._x + (enemies[i]._width/2) + 1, enemies[i]._y, true)){
  645.             rightWall_a[i] = 1;
  646.         }else{
  647.             rightWall_a[i] = 0;
  648.         }
  649.    
  650.         if(level.ground.hitTest(enemies[i]._x - (enemies[i]._width/2) + 1, enemies[i]._y, true)){
  651.             leftWall_a[i] = 1;
  652.         }else{
  653.             leftWall_a[i] = 0;
  654.         }
  655.         while(level.ground.hitTest(enemies[i]._x,enemies[i]._y + (enemies[i]._height/2) - 7, true)){
  656.  
  657.             enemies[i]._y -= 1;
  658.         }
  659.         while(level.ground.hitTest(enemies[i]._x + (enemies[i]._width/2), enemies[i]._y, true)){
  660.             enemies[i]._x -= 1;
  661.         }
  662.         while(level.ground.hitTest(enemies[i]._x - (enemies[i]._width/2), enemies[i]._y, true)){
  663.             enemies[i]._x += 1;
  664.         }
  665.        
  666.         if(outside.hitTest(enemies[i]._x,enemies[i]._y,true)){
  667.             removeEnemy(0);
  668.         }
  669.     }
  670. }
  671. pUps = new Array();
  672. pTypes = new Array();
  673.  
  674. function pMoves(){
  675.     for(i = pUps.length - 1; i >= 0; i--){
  676.         pUps[i]._x -= xSpeed;
  677.         pUps[i]._y -= ySpeed;
  678.         while(level.ground.hitTest(pUps[i]._x, pUps[i]._y + (pUps[i]._height/2), true)){
  679.             pUps[i]._y -= .2;
  680.         }
  681.         while(!level.ground.hitTest(pUps[i]._x, pUps[i]._y + (pUps[i]._height/2), true)){
  682.             pUps[i]._y += .2;
  683.         }
  684.         if(player.hitTest(pUps[i])){
  685.             if(pTypes[i] == 3){
  686.                 money += wave*10;
  687.             }
  688.             if(pTypes[i] == 1){
  689.                 health += 2;
  690.                 if(health >= 100){
  691.                     health = 100;
  692.                 }
  693.             }
  694.             if(pTypes[i] == 2){
  695.                 ammo[gunUsed] += 50;
  696.             }
  697.             updateStats();
  698.             pCol.start();
  699.             pCol.start();
  700.             deadEnemies.push(pUps[i]);
  701.             pUps[i].gotoAndStop(2);
  702.             pUps.splice(i,1);
  703.             pTypes.splice(i,1);
  704.         }
  705.     }
  706. }
  707.  
  708. enemyWorth = new Array(10, 20, 30);
  709.  
  710. function removeEnemy(ner){
  711.     //enemies[i].removeMovieClip();
  712.     kills += 1;
  713.     score += enemyWorth[enemyType[i]-1];
  714.     updateStats();
  715.     var pType = randRange(1,3);
  716.     if(pType == 1){
  717.         power = attachMovie("p1", "p" + depth, depth);
  718.         depth++;
  719.     }
  720.     if(pType == 2){
  721.         power = attachMovie("p2", "p" + depth, depth);
  722.         depth++;
  723.     }
  724.     if(pType == 3){
  725.         power = attachMovie("p3", "p" + depth, depth);
  726.         depth++;
  727.     }
  728.     power._x = enemies[i]._x;
  729.     power._y = enemies[i]._y;
  730.     power._xscale = power._yscale = 75;
  731.     pUps.push(power);
  732.     pTypes.push(pType);
  733.     enemies[i].gotoAndStop(3);
  734.     if(ner == 1){
  735.         enemies[i].gotoAndStop(4);
  736.     }
  737.             enemies.splice(i,1);
  738.             //Enemy vars
  739.             fallingSpeedA.splice(i,1);
  740.             delayA.splice(i,1);
  741.             shootingA.splice(i,1);
  742.             leftWall_a.splice(i,1);
  743.             rightWall_a.splice(i,1);
  744.             rightA.splice(i,1);
  745.             touchingGroundA.splice(i,1);
  746.             fallingA.splice(i,1);
  747.             duckingA.splice(i,1);
  748.             jumpingA.splice(i,1);
  749.             enemyLives.splice(i,1);
  750.             rightSpeed.splice(i,1);
  751.             leftSpeed.splice(i,1);
  752.             enemyType.splice(i,1);
  753. }
  754.  
  755. deadEnemies = new Array();
  756. function deadEnemiesMovement(){
  757.     for(i = deadEnemies.length -1; i >= 0; i--){
  758.         deadEnemies[i]._x -= xSpeed;
  759.         deadEnemies[i]._y -= ySpeed;
  760.         if(!level.ground.hitTest(deadEnemies[i]._x, deadEnemies[i]._y + 30, true)){
  761.             deadEnemies[i]._y += 10;
  762.         }
  763.         if(deadEnemies[i].q._currentframe == undefined){
  764.             deadEnemies.splice(i,1);
  765.         }
  766.     }
  767. }
  768.  
  769. function randRange(smallNum:Number, bigNum:Number):Number {
  770.     return (Math.floor(Math.random()*(bigNum-smallNum+1))+smallNum);
  771. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement