
Untitled
By: a guest on
Aug 19th, 2012 | syntax:
ActionScript | size: 1.89 KB | hits: 43 | expires: Never
// Bullet movement (strangely enough)
moveBullets = function ()
{
// Well this is a convoluted fucking mess
// Loops through bullets
for (i = 0; i < bulletList.length; i++)
{
var bul:MovieClip = _root["bullet" + bulletList[i]];
// Moves bullet the direction it should be going
bul.life --
if(bul.life == 0){
bul.gotoAndPlay("Dead")
}
bul._x += bulletSpeed * Math.sin(bul._rotation * Math.PI / 180);
bul._y -= bulletSpeed * Math.cos(bul._rotation * Math.PI / 180);
// if the bullet is out of the screen
if ((bul._x < -100) || (bul._x > 750) || (bul._y < -100) || (bul._y > 550))
{
// GTFO, bullet
bul.gotoAndPlay("Dead")
// copypasta'd loop is copypasta'd
for (b = 0; b < bulletList.length; b++)
{
// removes bullet from the array
if (bulletList[b] == bulletList[i])
{
bulletList.splice(b,1);
break;
}
}
}
// Well fuck, more nested loops
for (a = 0; a < enemyList.length; a++)
{
var en:MovieClip = _root["enemy" + enemyList[a]];
// If the bullet hits an enemy
if (en.hitTest(bul))
{
// damage the enemy
en.health -= bulletDamage[bulletType];
en.healthBar._width = (en.health / en.maxHealth) * 100
// OH GOD WHEN WILL IT STOP
for (b = 0; b < bulletList.length; b++)
{
// remove the bullet from the array
if (bulletList[b] == bulletList[i])
{
bulletList.splice(b,1);
break;
}
}
// remove bullet from the screen
bul.gotoAndPlay("Dead")
if (en.health <= 0)
{
// removes enemy from the array if it is dead
for (c = 0; c < enemyList.length; c++)
{
if (enemyList[c] == enemyList[a])
{
enemyList.splice(c,1);
break;
}
}
// deletes enemy on death
money += en.money
en.removeMovieClip();
}
}
}
}
};
// And breathe