Current Classes

Master Scholars!

RoachStuff.zip

Ship Game Code

Creating Projectiles

Add this inside of onClipEvent(load) below;

var ROF=6;
var ROFCount=0;
var bulletCount = 0;
var MAXBULLETS = 20;

_root.createEmptyMovieClip(“projectileLayer”,99);

createProjectile = function(type,sx,sy,angle,count)
{
var nm = “proj”+count;
_root.projectileLayer.attachMovie(type,nm,count);
_root.projectileLayer[nm]._x = sx;
_root.projectileLayer[nm]._y = sy;
_root.projectileLayer[nm]._rotation = angle;

_root.projectileLayer[nm].onEnterFrame = function()
{
var speed = 20;
this._x += speed;
}
}

Collision Detection

Add this in onClipEvent(load) after createEnemy
resetGame = function()
{
//We’ll add stuff in here later
}

collisionDetection = function()
{
for(i = 0;i<MAXENEMIES;i++)
{
if(this.hitTest(_root.enemyLayer[“enemy”+i]))
{
resetGame();

}
}
for(i=0;i<MAXENEMIES;i++)
{
for(j=0;j<MAXBULLETS;j++)
{
if(_root[“enemy”+i].hitTest(_root.projectileLayer[“proj”+j]))
{
_root [“enemy”+i].removeMovieClip();
_root.projectileLayer[“proj”+j].removeMovieClip();
}
}
}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s