forked from: [Stardust] forked from: 土着神「宝永四年の赤蛙」
東方風神録のスペル、土着神「宝永四年の赤蛙」風なものを作ってみた
マウスカーソルについてきます
3匹にはなりませんが
Stardustにしてみた。
@author paq89
// forked from paq's [Stardust] forked from: 土着神「宝永四年の赤蛙」
// forked from Susisu's 土着神「宝永四年の赤蛙」
/* 東方風神録のスペル、土着神「宝永四年の赤蛙」風なものを作ってみた
* マウスカーソルについてきます
* 3匹にはなりませんが
*/
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.geom.Point;
import frocessing.color.ColorHSV;
import idv.cjcat.stardust.common.actions.Age;
import idv.cjcat.stardust.common.actions.AlphaCurve;
import idv.cjcat.stardust.common.actions.CompositeAction;
import idv.cjcat.stardust.common.actions.DeathLife;
import idv.cjcat.stardust.common.actions.triggers.DeathTrigger;
import idv.cjcat.stardust.common.clocks.SteadyClock;
import idv.cjcat.stardust.common.initializers.Color;
import idv.cjcat.stardust.common.initializers.Life;
import idv.cjcat.stardust.common.initializers.Mask;
import idv.cjcat.stardust.common.math.UniformRandom;
import idv.cjcat.stardust.common.renderers.Renderer;
import idv.cjcat.stardust.twoD.actions.Damping;
import idv.cjcat.stardust.twoD.actions.Gravity;
import idv.cjcat.stardust.twoD.actions.Move;
import idv.cjcat.stardust.twoD.actions.Spawn;
import idv.cjcat.stardust.twoD.emitters.Emitter2D;
import idv.cjcat.stardust.twoD.fields.UniformField;
import idv.cjcat.stardust.twoD.initializers.Position;
import idv.cjcat.stardust.twoD.initializers.Velocity;
import idv.cjcat.stardust.twoD.renderers.PixelRenderer;
import idv.cjcat.stardust.twoD.zones.LazySectorZone;
import idv.cjcat.stardust.twoD.zones.SinglePoint;
/**
* Stardustにしてみた。
* @author paq89
*/
[SWF(backgroundColor="0xFF00DD", width=465, height=465, frameRate=60)]
public class Rain extends Sprite
{
private const ZERO_POINT:Point = new Point(0, 0);
private var _emitter:Emitter2D;
private var _bmpData:BitmapData;
private var _stgBmp:Bitmap;
private var _point:SinglePoint;
private var _blurFilter:BlurFilter;
private var _color:Color;
private var _hsv:ColorHSV;
public function Rain():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
graphics.beginFill(0); graphics.drawRect(0, 0, 465, 465);
_bmpData = new BitmapData(465, 465, true, 0x00000000);
_stgBmp = new Bitmap(_bmpData);
_point = new SinglePoint();
_blurFilter = new BlurFilter(2, 2, 1);
_color = new Color();
_hsv = new ColorHSV(0, 0.8);
_emitter = new Emitter2D(new SteadyClock(1));
var renderer:PixelRenderer = new PixelRenderer(_bmpData);
renderer.addEmitter(_emitter);
_emitter.addInitializer(_color);
_emitter.addInitializer(new Position(_point));
_emitter.addInitializer(new Life(new UniformRandom(100, 0)));
var trigger:DeathTrigger = new DeathTrigger();
var spawn:Spawn = new Spawn(new UniformRandom(20, 20));
spawn.addInitializer(new Mask(2));
spawn.addInitializer(_color)
spawn.addInitializer(new Life(new UniformRandom(20, 20)));
spawn.addInitializer(new Velocity(new LazySectorZone(5, 5)));
trigger.mask = 1;
trigger.addAction(spawn);
var commonActions:CompositeAction = new CompositeAction();
commonActions.mask = 1 | 2;
commonActions.addAction(new Move());
commonActions.addAction(new DeathLife());
commonActions.addAction(new Age());
commonActions.addAction(new AlphaCurve(10, 20));
commonActions.addAction(new Damping(0.1));
_emitter.addAction(commonActions);
_emitter.addAction(trigger);
addChild(_stgBmp);
addEventListener(Event.ENTER_FRAME, loop);
}
private function loop(e:Event):void
{
_hsv.h += 5;
_color.color = _hsv.value32;
_bmpData.applyFilter(_bmpData,_bmpData.rect, ZERO_POINT, _blurFilter);
_point.x = mouseX;
_point.y = mouseY;
_emitter.step();
}
}
}