package {
/*
えんとろぴーが ぞうだいする!
*/
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.display.Sprite;
import flash.geom.Point;
public class FlashTest extends Sprite {
public var particles:Vector.<Particle>=new Vector.<Particle>();
public var canvas:BitmapData=new BitmapData(495,495);
public var bmp:Bitmap=new Bitmap(canvas);
public function FlashTest() {
for(var i:int=0;i<100;i++){
for(var j:int=0;j<100;j++){
var r:Number=Math.random()*2*Math.PI;
particles.push(new Particle(i+465/2-50,j+465/2-50,Math.cos(r),Math.sin(r)));
}
}
canvas.setPixel32(1,1,0xffff0000);
addChild(bmp);
addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
public function onEnterFrame(e:Event):void{
canvas.fillRect(canvas.rect,0);
for(var i:int=0;i<10000;i++){
particles[i].x+=particles[i].v.x;
particles[i].y+=particles[i].v.y;
if(particles[i].x<0){particles[i].x=0;particles[i].v.x=0;}
else if(particles[i].x>465){particles[i].x=465;particles[i].v.x=0;}
if(particles[i].y<0){particles[i].y=0;particles[i].v.y=0;}
else if(particles[i].y>465){particles[i].y=465;particles[i].v.y=0;}
var r:Number=Math.random()*2*Math.PI;
var p:Point=new Point(Math.cos(r)*0.125,Math.sin(r)*0.125);
particles[i].v=particles[i].v.add(p);
canvas.setPixel32(particles[i].x,particles[i].y,0xff000000);
}
}
}
}
import flash.geom.Point;
class Particle{
public var x:Number=0;
public var y:Number=0;
public var v:Point=new Point(0,0);
public function Particle(x:Number,y:Number,vx:Number,vy:Number){
this.x=x;
this.y=y;
this.v.x=vx;
this.v.y=vy;
}
}