Frtn
12-28-2007, 11:53 AM
Hello I am working on a project, and I'm planning to make a flash lava lamp.
I am currently working on the "giving heat to the blobs" part of the project.
Currently it looks something like this:
Link (http://filexoom.com/files/91669/Trails.swf)
And the code:
var b:Bitmap = new Bitmap();
addChild(b);
var bd:BitmapData = new BitmapData(550,400);
var ct:ColorTransform = new ColorTransform;
var rect:Rectangle = new Rectangle(5,5,5,5);
bd.fillRect(bd.rect,0xffff0000);
import flash.display.Stage;
stage.scaleMode = "noScale";
rect.width = 1;
rect.height = rect.width;
b.bitmapData = bd;
var sprite:Sprite = new Sprite();
var mc:MovieClip = new MovieClip();
//mc.graphics.beginFill(0xff0000);
mc.graphics.drawCircle(0,0,1);
//mc.graphics.endFill();
sprite.addChild(mc);
this.addChild(sprite);
this.addEventListener(Event.ENTER_FRAME,rs);
var dist:Number = 25;
function rs(e:Event):void{
for(rect.x=mouseX-dist;rect.x<mouseX+dist;rect.x++){
for(rect.y=mouseY-dist;rect.y<mouseY+dist;rect.y++){
var dist2:Number = Point.distance(new Point(mouseX,mouseY),new Point(rect.x,rect.y));
if(dist2<dist){
/*var newPixel:uint = bd.getPixel( rect.x , rect.y );
var red:Number = newPixel>>16&0xff;
var green:Number = newPixel>>8&0xff;
var blue:Number = newPixel&0xff;*/
//ct.redOffset = 255;
ct.greenOffset = 5 * (dist-dist2) ;
bd.colorTransform(rect,ct);
}
}
}
bd.draw(sprite);
ct.greenOffset = -2;
bd.colorTransform(bd.rect,ct);
}
So...
In the next part of the project I will generate some randomly shaped blobs of liquid and place them in a movie.
And then they will find out the amount of yellow inside to get the average "temperature" of the blob, and then the upwards acceleration of the blobs will be determined. So if the blob is relatively hot, it will flow upwards, if it's low, it will flow downwards. As it gets higher, the blob will lose some heat. Touching another blob will exchange some heat and other lava-lamp'ish stuff will happen.
Do you think I should do it with pixels? (like above) or do you think I should use "normal flash stuff" ?
Is my method of displaying "heat" good? Or could I use another way?
(I will transfer heat through convection and conduction, but not radiation, that would be difficult to emulate heh..)
Any kind of help is welcome.
I am currently working on the "giving heat to the blobs" part of the project.
Currently it looks something like this:
Link (http://filexoom.com/files/91669/Trails.swf)
And the code:
var b:Bitmap = new Bitmap();
addChild(b);
var bd:BitmapData = new BitmapData(550,400);
var ct:ColorTransform = new ColorTransform;
var rect:Rectangle = new Rectangle(5,5,5,5);
bd.fillRect(bd.rect,0xffff0000);
import flash.display.Stage;
stage.scaleMode = "noScale";
rect.width = 1;
rect.height = rect.width;
b.bitmapData = bd;
var sprite:Sprite = new Sprite();
var mc:MovieClip = new MovieClip();
//mc.graphics.beginFill(0xff0000);
mc.graphics.drawCircle(0,0,1);
//mc.graphics.endFill();
sprite.addChild(mc);
this.addChild(sprite);
this.addEventListener(Event.ENTER_FRAME,rs);
var dist:Number = 25;
function rs(e:Event):void{
for(rect.x=mouseX-dist;rect.x<mouseX+dist;rect.x++){
for(rect.y=mouseY-dist;rect.y<mouseY+dist;rect.y++){
var dist2:Number = Point.distance(new Point(mouseX,mouseY),new Point(rect.x,rect.y));
if(dist2<dist){
/*var newPixel:uint = bd.getPixel( rect.x , rect.y );
var red:Number = newPixel>>16&0xff;
var green:Number = newPixel>>8&0xff;
var blue:Number = newPixel&0xff;*/
//ct.redOffset = 255;
ct.greenOffset = 5 * (dist-dist2) ;
bd.colorTransform(rect,ct);
}
}
}
bd.draw(sprite);
ct.greenOffset = -2;
bd.colorTransform(bd.rect,ct);
}
So...
In the next part of the project I will generate some randomly shaped blobs of liquid and place them in a movie.
And then they will find out the amount of yellow inside to get the average "temperature" of the blob, and then the upwards acceleration of the blobs will be determined. So if the blob is relatively hot, it will flow upwards, if it's low, it will flow downwards. As it gets higher, the blob will lose some heat. Touching another blob will exchange some heat and other lava-lamp'ish stuff will happen.
Do you think I should do it with pixels? (like above) or do you think I should use "normal flash stuff" ?
Is my method of displaying "heat" good? Or could I use another way?
(I will transfer heat through convection and conduction, but not radiation, that would be difficult to emulate heh..)
Any kind of help is welcome.