Guest User

Untitled

a guest
Sep 21st, 2018
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Bullet movement (strangely enough)
  2. moveBullets = function ()
  3. {
  4.     // Well this is a convoluted fucking mess
  5.    
  6.     // Loops through bullets
  7.     for (i = 0; i < bulletList.length; i++)
  8.     {
  9.         var bul:MovieClip = _root["bullet" + bulletList[i]];
  10.         // Moves bullet the direction it should be going
  11.         bul.life --
  12.         if(bul.life == 0){
  13.             bul.gotoAndPlay("Dead")
  14.         }
  15.         bul._x += bulletSpeed * Math.sin(bul._rotation * Math.PI / 180);
  16.         bul._y -= bulletSpeed * Math.cos(bul._rotation * Math.PI / 180);
  17.        
  18.         // if the bullet is out of the screen
  19.         if ((bul._x < -100) || (bul._x > 750) || (bul._y < -100) || (bul._y > 550))
  20.         {
  21.             // GTFO, bullet
  22.             bul.gotoAndPlay("Dead")
  23.             // copypasta'd loop is copypasta'd
  24.             for (b = 0; b < bulletList.length; b++)
  25.             {
  26.                 // removes bullet from the array
  27.                 if (bulletList[b] == bulletList[i])
  28.                 {
  29.                     bulletList.splice(b,1);
  30.                     break;
  31.                 }
  32.             }
  33.         }
  34.         // Well fuck, more nested loops
  35.         for (a = 0; a < enemyList.length; a++)
  36.         {
  37.             var en:MovieClip = _root["enemy" + enemyList[a]];
  38.             // If the bullet hits an enemy
  39.             if (en.hitTest(bul))
  40.             {
  41.                 // damage the enemy
  42.                 en.health -= bulletDamage[bulletType];
  43.                 en.healthBar._width = (en.health / en.maxHealth) * 100
  44.                 // OH GOD WHEN WILL IT STOP
  45.                 for (b = 0; b < bulletList.length; b++)
  46.                 {
  47.                     // remove the bullet from the array
  48.                     if (bulletList[b] == bulletList[i])
  49.                     {
  50.                         bulletList.splice(b,1);
  51.                         break;
  52.                     }
  53.                 }
  54.                 // remove bullet from the screen
  55.                 bul.gotoAndPlay("Dead")
  56.                 if (en.health <= 0)
  57.                 {
  58.                     // removes enemy from the array if it is dead
  59.                     for (c = 0; c < enemyList.length; c++)
  60.                     {
  61.                         if (enemyList[c] == enemyList[a])
  62.                         {
  63.                             enemyList.splice(c,1);
  64.                             break;
  65.                         }
  66.                     }
  67.                     // deletes enemy on death
  68.                     money += en.money
  69.                     en.removeMovieClip();
  70.                    
  71.                 }
  72.             }
  73.         }
  74.     }
  75. };
  76. // And breathe
Add Comment
Please, Sign In to add comment