Flintstance
/**
* Copyright hemingway ( http://wonderfl.net/user/hemingway )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/emNu
*/
package
{
import net.hires.debug.*;
import flash.display.*;
import flash.system.*;
import flash.events.*;
import flash.utils.*;
import flash.geom.*;
import flash.text.*;
import org.flintparticles.common.counters.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.displayObjects.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.renderers.*;
import org.flintparticles.twoD.initializers.*;
[SWF(frameRate = 60, width = 465, height = 465)]
public class Main extends Sprite
{
private var emitter :Emitter2D;
private var renderer :BitmapRenderer;
internal var initPt :Point = new Point();
internal var clcPt :Point = new Point();
internal var curPt :Point = new Point();
internal var gravityWell :GravityWell;
internal var discZone :DiscZone;
public function Main()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
addEventListener(Event.ADDED_TO_STAGE, addedToStage);
emitter = new Flintstance();
renderer = new BitmapRenderer(new Rectangle(0, 0, 464, 464));
gravityWell = new GravityWell(0, 1, 1, 465);
renderer.addEmitter(emitter);
}
public function _init() :void
{
graphics.clear ();
graphics.lineStyle (1, 0, 0.75);
graphics.drawRect (0, 0, 464, 464);
}
public function addedToStage($e:Event) :void
{
removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
addChild(renderer);
addChild(new Stats);
_init();
emitter.start();
emitter.addAction(gravityWell);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
}
public function onMouseDown($e:MouseEvent) :void
{
initPt = new Point($e.stageX, $e.stageY);
gravityWell.power = 100000;
stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}
public function onMouseMove($e:MouseEvent) :void
{
curPt = new Point($e.stageX, $e.stageY);
clcPt = curPt.subtract(initPt);
gravityWell.x = $e.stageX;
gravityWell.y = $e.stageY;
initPt = curPt;
}
public function onMouseUp($e:MouseEvent) :void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
gravityWell.power = 0;
}
}
}
import org.flintparticles.common.counters.*;
import org.flintparticles.common.initializers.*;
import org.flintparticles.common.displayObjects.*;
import org.flintparticles.twoD.zones.*;
import org.flintparticles.twoD.actions.*;
import org.flintparticles.twoD.emitters.*;
import org.flintparticles.twoD.initializers.*;
class Flintstance extends Emitter2D
{
public function Flintstance()
{
counter = new Blast( 100 );
addInitializer( new SharedImage( new Dot( 12 ) ) );
addInitializer( new MassInit ( 100 ) );
addInitializer( new ColorInit( 0xFF000000, 0xFF000000 ) );
addInitializer( new Position( new RectangleZone( 0, 0, 464, 464 ) ) );
addInitializer( new CollisionRadiusInit( 12 ) );
addAction( new MinimumDistance( 1000, 12 ) );
addAction( new BoundingBox( 0, 0, 464, 464 ) );
addAction( new SpeedLimit( 600 ) );
addAction( new Friction( 5 ) );
addAction( new Collide() );
addAction( new Move() );
}
}