forked from: flash on 2013-1-22
/**
* Copyright makc3d ( http://wonderfl.net/user/makc3d )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/g4x4
*/
// forked from mutantleg's flash on 2013-1-22
package {
import flash.events.Event;
import flash.geom.*;
import flash.display.*;
public class FlashTest extends Sprite {
public var bd:BitmapData, ct:ColorTransform;
public function FlashTest() {
addChild(new Bitmap (bd = new BitmapData ( 465, 465, false, 0xFFFFFF)));
ct = new ColorTransform (1, 1, 1, 1, 10 * Math.random (), 10 * Math.random (), 10 * Math.random ());
graphics.clear();
graphics.lineStyle(0,0);
vec = new Vector.<wNode>(0,false);
var w:wNode;
w = new wNode(232,232);
vec.push(w);
stage.addEventListener(Event.ENTER_FRAME, onEnter);
}//ctor
public var vec:Vector.<wNode>;
public function onEnter(e:Event):void
{
var w:wNode;
var m:wNode;
var num:int;
graphics.clear();
var k:int;
num = vec.length;
var anybodyLives:Boolean;
for (k = 0; k < num; k++)
{
w = vec[k];
if (w.hp <= 0)
{
continue;
}
graphics.lineStyle(w.hp*0.1,0)
graphics.moveTo(w.px, w.py);
graphics.lineTo(w.cx,w.cy);
w.px = w.cx;
w.py = w.cy;
var dcx:Number = Math.cos(w.ang) * 8;
var dcy:Number = Math.sin(w.ang) * 8;
w.ang += (Math.random()-Math.random());
w.hp -=1;
if (w.hp <= 0)
{ graphics.drawCircle(w.cx+dcx/2,w.cy+dcy/2, 4); }
else
{ anybodyLives = true; w.cx+=dcx; w.cy+=dcy;
if (num < 32)
if (Math.random() < 0.15)
{
// graphics.drawCircle(w.cx,w.cy, 4);
m = new wNode(w.cx, w.cy);
m.ang = w.ang + (Math.random()-Math.random());
m.hp = w.hp / 2;
//w.hp /= 2;
vec.push(m);
}//endif
}
}//nextk
if (!anybodyLives) {
ct = new ColorTransform (1, 1, 1, 1, 10 * Math.random (), 10 * Math.random (), 10 * Math.random ());
graphics.clear();
vec = new Vector.<wNode>;
w = new wNode(232,232);
w.ang = 2 * Math.PI * Math.random();
vec.push(w);
}
var bmp:* = removeChildAt(0);
bd.draw (this);
bd.colorTransform(bd.rect, ct);
addChild(bmp);
}//onenter
}//classend
}
internal class wNode
{
public var ang:Number = 0;
public var cx:Number = 0;
public var cy:Number = 0;
public var hp:Number = 0;
public var px:Number = 0;
public var py:Number = 0;
public function wNode(x:Number, y:Number)
{
cx = x;
cy = y;
px = x;
py = y;
hp = 50;
}//ctor
}//wnode