Effects
Effect View:
Click here to download the source file
Scene Code:
Object.environment = this;
Math.prototype.degrees = function (r)
{
Return (R * 180/3.141593e+000);
};
Maxtents = 3;
This.onenterframe = function ()
{
if (!random && tents < maxtents)
{
var nombre = "Tent" + String (depth++);
var Neo = This.attachmovie ("Tentacle", nombre, depth);
neo._x = random (600);
neo._y = 370;
Neo.theta = 270;
++tents;
}//End If
};
Stop ();
code in the MC:
#initclip 1
function Tentacleclass ()
{
This.numnodes = 27;
This.head = 2 + random (4);
This.girth = 8 + random (12);
This.speedcoefficient = 9.000000E-002 + random (10)/50;
This.friction = 9.000000E-001 + random (10)/100;
This.musclerange = + random (50);
This.musclefreq = 1.000000E-001 + random (100)/250;
This.generatenodes ();
This.onenterframe = This.move;
}//End of the function
Tentacleclass.prototype = new MovieClip ();
TentacleClass.prototype.generateNodes = function ()
{
This.node = new Array ();
var n = 0;
while (n < this.numnodes)
{
var point = {x:0, y:0};
This.node.push (point);
++n;
}//End While
};
TentacleClass.prototype.move = function ()
{
this.tv = this.tv + 5.000000E-001 * (Math.random ()-math.random ());
This.theta = This.theta + this.tv;
this.tv = this.tv * this.friction;
this.node[0].x = This.head * Math.Cos (1.745329E-002 * this.theta);
THIS.NODE[0].Y = This.head * Math.sin (1.745329E-002 * this.theta);
This.count = This.count + this.musclefreq;
this.thetamuscle = This.musclerange * Math.sin (This.count);
this.node[1].x =-this.head * Math.Cos (1.745329E-002 * (This.theta + this.thetamuscle));
THIS.NODE[1].Y =-this.head * Math.sin (1.745329E-002 * (This.theta + this.thetamuscle));
var i = 2;
while (I < this.numnodes)
{
var dx = this.node.x-this.node[i-2].x;
var dy = this.node.y-this.node[i-2].y;
var d = math.sqrt (dx * dx + dy * dy);
this.node.x = this.node[i-1].x + dx * THIS.GIRTH/D;
This.node.y = this.node[i-1].y + dy * this.girth/d;
if (i = = 2)
{
this._x = This._x-dx * this.speedcoefficient;
this._y = This._y-dy * this.speedcoefficient;
if (this._x + this._width < 0 | | | this._x-this._width > | | this._y + this._height < 0 | | this._y-this._hei Ght > 400)
{
--object.environment.tents;
This.removemovieclip ();
}//End If
}//End If
++i;
}//End While
This.clear ();
This.moveto (this.node[1].x, THIS.NODE[1].Y);
var i = 2;
while (I < this.numnodes)
{
This.linestyle (int (this.numnodes-i) * (this.numnodes-i)/20, 16777215, 100);
This.lineto (this.node.x, this.node.y);
++i;
}//End While
};
Object.registerclass ("Tentacle", tentacleclass);
#endinitclip