Element Physics Experimental
Copyright 2011, Kaiyi Chan
Experimental Physics game.
Press mouse to place an element.
Press space to remove excess elements.
Switch from elements using the panel.
Write comments for more elements or ideas!
========================================
-> bugs notifier:
liquid physics beta.
-> upcoming changes:
more elements / better User Interface.
better physics for all elements (gases, liquids, solids) based on true physics.
shift element placement techniques.
rover (explorer).
drag mode.
shortcut keys for elements.
speed adjusting panel.
/*
Copyright 2011, Kaiyi Chan
Experimental Physics game.
Press mouse to place an element.
Press space to remove excess elements.
Switch from elements using the panel.
Write comments for more elements or ideas!
========================================
-> bugs notifier:
liquid physics beta.
-> upcoming changes:
more elements / better User Interface.
better physics for all elements (gases, liquids, solids) based on true physics.
shift element placement techniques.
rover (explorer).
drag mode.
shortcut keys for elements.
speed adjusting panel.
*/
package
{
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.text.Font;
import flash.text.TextFormat;
import flash.utils.getTimer;
import flash.utils.Timer;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.events.Event;
[SWF(backgroundColor=0x000015)]
public class dots extends Sprite
{
/* User Configureables */
private var Density:Number = 1;
private var scaleBM:int = 3;
private const BOXLEFT:int = 0;
private const BOXRIGHT:int = 465;
private const BOXUP:int = 0;
private const BOXDOWN:int = 380; //460
private const fps:int = (1000/30);
private const maxDots = 2000;
/* Misc */
private var input:TextField;
private var elements:Elements = new Elements();
private var selector:Sprite = new Sprite();
private var MOUSE_ACTIVATE:Boolean = false;
private var bmd:BitmapData;
private var bmdCopy:BitmapData;
private var size:Sprite;
private var save:Sprite;
private var onFrame:Timer;
private var prevTime:int = 0;
private var running:Boolean = true;
private var pull:Boolean = false;
private var numberOfDots = 0;
public function dots() { onLoad(); }
public function onLoad():void
{
/* initialization Bitmapscreen */
bmd = new BitmapData(BOXRIGHT/scaleBM, BOXDOWN/scaleBM, false, 0);
var bm:Bitmap = new Bitmap(bmd);
bm.scaleY = scaleBM;
bm.scaleX = scaleBM;
addChild(bm);
var bg:Sprite = new Sprite();
bg.graphics.beginFill(0x335555);
bg.graphics.drawRect(0, BOXDOWN, BOXRIGHT, 460-BOXDOWN);
bg.graphics.endFill();
addChild(bg);
/* create mainframe */
this.input = mainframe();
this.input.defaultTextFormat=LetterType("Georgia", 11);
/* create updater */
onFrame = new Timer(fps);
onFrame.addEventListener(TimerEvent.TIMER, update);
onFrame.start();
/* Event Listeners */
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseClickDown);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseClickUp);
/* buttons */
ElementButton(BOXLEFT+010, BOXDOWN+00, elements.Sand());
ElementButton(BOXLEFT+010, BOXDOWN+15, elements.Stone());
ElementButton(BOXLEFT+010, BOXDOWN+30, elements.Iron());
ElementButton(BOXLEFT+010, BOXDOWN+45, elements.Water());
ElementButton(BOXLEFT+010, BOXDOWN+60, elements.Ice());
ElementButton(BOXLEFT+110, BOXDOWN+00, elements.Wood());
ElementButton(BOXLEFT+110, BOXDOWN+15, elements.Fire());
ElementButton(BOXLEFT+110, BOXDOWN+30, elements.Dynamite());
ElementButton(BOXLEFT+110, BOXDOWN+45, elements.Lava());
ElementButton(BOXLEFT+110, BOXDOWN+60, elements.Methane());
ElementButton(BOXLEFT+210, BOXDOWN+00, elements.Human());
ElementButton(BOXLEFT+210, BOXDOWN+15, elements.Ufo());
ElementButton(BOXLEFT+210, BOXDOWN+30, elements.Cloud());
ElementButton(BOXLEFT+210, BOXDOWN+45, elements.Laser());
ElementButton(BOXLEFT+210, BOXDOWN+60, elements.Wall());
ElementButton(BOXLEFT+310, BOXDOWN+30, elements.Torch());
ElementButton(BOXLEFT+310, BOXDOWN+45, elements.Slime());
ElementButton(BOXLEFT+310, BOXDOWN+60, elements.Glue());
/* Functions */
ElementButton(BOXLEFT+310, BOXDOWN+00, elements._Erase());
ElementButton(BOXLEFT+310, BOXDOWN+15, elements._Drag());
FunctionButton(BOXLEFT+410, BOXDOWN+00, "Size").addEventListener(MouseEvent.CLICK, setSize);
FunctionButton(BOXLEFT+410, BOXDOWN+15, "Pause").addEventListener(MouseEvent.CLICK, pause);
FunctionButton(BOXLEFT+410, BOXDOWN+45, "Save").addEventListener(MouseEvent.CLICK, saveBmd);
FunctionButton(BOXLEFT+410, BOXDOWN+60, "Load").addEventListener(MouseEvent.CLICK, loadBmd);
/* Selector */
selector.graphics.beginFill(0xFFFFFF);
selector.graphics.drawCircle(5, BOXDOWN+10, 2);
selector.graphics.endFill();
stage.addChild(selector);
for (var i:int=0; i<=BOXRIGHT; i++)
{
this.bmd.setPixel(i, bmd.height-1, this.elements.Wall().color);
this.bmd.setPixel(i, bmd.height-2, this.elements.Wall().color);
}
}
public function setSize(e:MouseEvent):void { this.Density*=2; if (this.Density>64) this.Density=1; }
public function saveBmd(e:MouseEvent):void { this.bmdCopy=this.bmd.clone(); }
public function loadBmd(e:MouseEvent):void { this.bmd.draw(this.bmdCopy); }
public function pause(e:MouseEvent):void { (running)? running=false : running=true; }
private function update(evt:TimerEvent):void
{
this.bmd.unlock();
/* get Frames per second */
var getfps:int = 1000 / (getTimer() - prevTime);
prevTime = getTimer();
/* update mainframe */
this.numberOfDots = countDots();
this.input.text = "\t\t\tfps: "+getfps+"\t\t\ttype: "+this.elements.type.name+"\t\tSize: "+this.Density+"\t\t\tdots: "+this.numberOfDots;
/* element creation */
mouseClickCreateDot();
if (running) elementHandler();
this.bmd.lock();
}
private function countDots():int
{
var value:int;
for (var x:int=0; x<=this.bmd.width; x++)
{
for (var y:int=this.bmd.height-1; y>=0;--y)
{
if (this.bmd.getPixel(x, y) != 0x0)
{
value+=1;
}
}
}
return value;
}
private function getC(x:int, y:int):uint { return this.bmd.getPixel(x, y); }
private function setC(x:int, y:int, c:int):void { this.bmd.setPixel(x, y, c); }
private function elementHandler():void
{
/*
creates gravity effect on all dots.
also handles other effects.
*/
var getPixelColor:uint;
var getCollisionColor:uint;
var scaler:int=10;
var e:Object;
var mX:int=mouseX/scaleBM;
var mY:int=mouseY/scaleBM;
var d:int=this.Density-1;
for (var y:int=this.bmd.height; y>=0; y--)
{
for (var x:int=this.bmd.width; x>=0; x--)
{
if (getC(x, 0)!=0) setC(x, 0, 0);
//skip if this is not an element.
getPixelColor = getC(x, y);
if (getPixelColor==0) continue;
//get element type.
e = this.elements.getElementByColor(getPixelColor);
/*
Global element settings.
*/
if (e.decay>0) { if (Math.random()> (1-e.decay/scaler)) {setC(x,y,0); continue;} }
if (e.flammable>0)
{
var burnE:Object=onTouch(x, y);
if (burnE!=null)
{
if (burnE.ignites && Math.random()> (1-e.flammable/scaler)) setC(x, y, elements.Fire().color);
}
}
/*
unique element settings.
*/
if (e.name=="Ufo" && getC(x, y+2)==e.color) setC(x, y+2, 0);
if (e.name=="Human" && getC(x, y+1)==e.color) setC(x, y+1, 0);
if (e.name=="Laser" && getC(x, y+1)==0 && Math.random()>.5) setC(x, y+1, e.color);
if (e.name=="Plant" && Math.random()>.8)
{
if (Math.random()>.9)
{
if (getC(x-1, y-1)==0) setC(x-1, y-1, e.color);
if (getC(x-2, y-2)==0) setC(x-2, y-2, e.color);
}
if (Math.random()>.9)
{
if (getC(x+1, y-1)==0) setC(x+1, y-1, e.color);
if (getC(x+2, y-2)==0) setC(x+2, y-2, e.color);
}
}
else if (e.name=="Plant" && Math.random() > .89)
{
setC(x, y, elements.Branch().color);
continue;
}
if (e.name=="Ufo" && y<=300)
{
if (Math.random()>.5)
{
if (getC(x, y+3)==0) setC(x, y+3, elements.Laser().color);
}else{
if (Math.random()>.5)
{
if (getC(x-1, y)==0) setC(x-1, y, elements.Ufo().color);
}else{
if (getC(x+1, y)==0) setC(x+1, y, elements.Ufo().color);
}
setC(x, y, 0);
}
continue;
}
var touch:Object=onTouch(x, y);
if (touch!=null && Math.random()>.5)
{
if (e.name=="Slime"&& touch.name!="Slime") continue;
if (e.name=="Iron" && touch.name=="Water" && Math.random()>.88) setC(x, y, elements.Rust().color);
if (e.name=="Iron" && touch.name=="Lava" && Math.random()>.99) setC(x, y, elements.Lava().color);
if (e.name=="Rust" && touch.name=="Fire" && Math.random()>.5) setC(x, y, elements.Iron().color);
if (e.name=="Rust" && touch.name=="Lava" && Math.random()>.5) setC(x, y, elements.Lava().color);
if (e.name=="Sand" && touch.name=="Lava" && Math.random()>.4) setC(x, y, elements.Lava().color);
if (e.name=="Stone" && touch.name=="Lava" && Math.random()>.9) setC(x, y, elements.Lava().color);
if (e.name=="Lava" && touch.name=="Water" && Math.random()>.4) setC(x, y, elements.Stone().color);
if (e.name=="Lava" && touch.name=="Water" && Math.random()>.4) setC(x, y, elements.Rust().color);
//if (e.name=="Lava" && touch.name=="Water" && Math.random()>.4) setC(x, y, 0);
if (e.name=="Lava" && touch.name=="Ice" && Math.random()>.4) setC(x, y, elements.Stone().color);
if (e.name=="Ice" && touch.name=="Lava" && Math.random()>.4) setC(x, y, elements.Water().color);
if (e.name=="Water" && touch.ignites && Math.random()>.7) setC(x, y, elements.Steam().color);
if (e.name=="Ice" && touch.ignites && Math.random()>.90) setC(x, y, elements.Water().color);
if (e.name=="Water" && touch.name=="Ice" && Math.random()>.10) setC(x, y, elements.Ice().color);
if (e.name=="Water" && touch.name=="Wood" && Math.random()>.991) setC(x, y, elements.Plant().color);
if (e.name=="Human" && touch.name=="Water" && Math.random()>.88) setC(x, y, elements.Steam().color);
if (e.name=="Torch" && touch.name=="Water" && Math.random()>.4) setC(x, y, elements.Steam().color);
if (e.name=="Torch" && touch.name=="Ice" && Math.random()>.4) setC(x, y, elements.Steam().color);
if (e.name=="Cloud" && Math.random()>.88) setC(x, y, elements.Water().color);
if (e.name=="Stone" && touch.name=="Lava" && Math.random()>.4) setC(x, y, elements.Lava().color);
continue;
}
if (e.name=="Torch" && Math.random()>.5)
{
for (var f:int=-1;f<2;f++) {
if (getC(x+f,y-1)==0) setC(x+f, y-1, elements.Fire().color);
}
}
/*
When pulling an element, skip physics.
*/
if (this.elements.getType().name == "Pull" && this.MOUSE_ACTIVATE)
{
if (x >= mX-(d/2) && x <=mX+d)
{
if (y >= mY-(d/2) && y <=mY+d)
{
continue;
}
}
}
/*
Element Physics.
*/
if (e.movable==0 && getC(x, y+1)!=0 && e.mass==0) continue;
var newx:int = (Math.random()>(1-e.movable/scaler))? ((Math.random()>.5)? x+(3-e.mass) : x-(3-e.mass)) : x;
var newy:int = y+getRand(e.mass)+0.5;
//standard gravity pull.
if (getC(x, newy) == 0)
{
setC(x, y, 0);
setC(x, newy, getPixelColor);
continue;
}
//liquids move left-right if there is an obstruction below.
if (getC(x, y+1) != 0)
{
if (getC(newx, y) == 0)
{
setC(x, y, 0);
setC(newx, y, getPixelColor);
continue;
}
}
//diffuse-system.
if (!e.movable)
{
getCollisionColor = getC(newx, newy);
var ee:Object = this.elements.getElementByColor(getCollisionColor);
if (ee.movable || e.movable)
{
if (getCollisionColor != getPixelColor)
{
if (ee.mass < e.mass)
{
setC(x, y, getCollisionColor);
setC(newx, newy, getPixelColor);
continue;
}
}
}
}
}
}
}
private function onTouch(x:int, y:int):Object
{
var pos:Array = new Array(-1, 0, 1);
var b:int;
for(b=0; b<3; b++) pos[b] = pos.splice(int(Math.random() * (3-b)), 1)[0];
/*
Gives a return of an nearby element not equal as element on x,y.
*/
for (var a:int=-1; a<=1; a++)
{
for (var c:String in pos)
{
b = pos[c];
if (getC(x+a, y+b)!=0 && getC(x+a, y+b)!=getC(x,y) && Math.random()>.5)
{
return this.elements.getElementByColor(getC(x+a, y+b));
}
}
}
return null;
}
private function mouseClickDown(evt:MouseEvent):void { this.MOUSE_ACTIVATE = true; }
private function mouseClickUp(evt:MouseEvent):void { this.MOUSE_ACTIVATE = false; }
private function mouseClickCreateDot():void
{
var mX:int=mouseX/scaleBM;
var mY:int=mouseY/scaleBM;
if (this.MOUSE_ACTIVATE)
{
if (!(mX > 0 && mX < this.bmd.width && mY > 0 && mY < this.bmd.height)) return;
/* spray-level */
var d:int = this.Density-1;
/* check functions */
if (this.elements.getType().name == "Erase")
{
for (var posx:int=mX-(d/2);posx<=mX+d;posx++)
{
for (var posy:int=mY-(d/2);posy<=mY+d;posy++)
{
this.bmd.setPixel(posx, posy, 0x000000);
}
}
return;
}
/*
Drag Mode Movement.
*/
if (this.elements.getType().name == "Pull")
{
for (var a:int=mX-(d/2); a<=mX+d; a++)
{
for (var b:int=mY-(d/2); b<=mY+d; b++)
{
if (getC(a, b)==0) continue;
var dir:int = (Math.atan2(mY-b, mX-a));
var newx:int = a+ Math.round(Math.cos(dir)*scaleBM);
var newy:int = b+ Math.round(Math.sin(dir)*scaleBM);
//if (newx<0) newx*=-1;
//if (newy<0) newy*=-1;
if (getC(newx, newy)==0)
{
var e:Object = this.elements.getElementByColor(getC(a, b));
if ( e.allowPull )
{
setC(newx, newy, getC(a, b));
setC(a, b, 0);
}
}
}
}
return;
}
if (this.elements.getType().isFunction) return;
/*
Place dots technique
*/
//don't exceed maximum number of dots
if (this.numberOfDots >= this.maxDots) return;
/* compact */
for (var x:int = mX-(d/2);x<=mX+(d/2);x++)
{
for (var y:int = mY-(d/2);y<=mY+(d/2);y++)
{
if (this.bmd.getPixel(x, y) == 0)
{
this.bmd.setPixel(x, y, this.elements.getType().color);
}
}
}
/* compact overwrite
if (mX > 0 && mX < 465 && mY > 0 && mY < 465)
{
this.bmd.fillRect(new Rectangle(mX-(d/2), mY-(d/2), d, d), this.elements.getType().color);
}
*/
/* spreader
if (mX > 0 && mX < 465 && mY > 0 && mY < 465)
{
for (var i:int = 0;i<=d;i++)
{
var posx:int= mX + (Math.random()*d)-(Math.random()*d)/2;
var posy:int= mY + (Math.random()*d)-(Math.random()*d)/2;
if (this.bmd.getPixel(posx, posy) == 0)
{
this.bmd.setPixel(posx, posy, this.elements.getType().color);
}
}
}
*/
}
}
private function getRand(x:Number, allowNegative:Boolean=false):Number {
/*
This function creates a random number between 0 and x or -x and x.
*/
var y:Number;
var z:Number;
var value:Number;
y = x;
z = (allowNegative)? Math.random() * (x*2) -x : Math.random() * x;
value = (allowNegative) ? ((Math.random()*x)+0.6) - ((Math.random()*x)) : x - (Math.random()*x);
return value; //y-z;
/*
z = (allowNegative)? (Math.random()>.5)? Math.random()*x : Math.random()*-x : Math.random()*x;
return z;
*/
}
private function ElementButton(x:Number, y:Number, e:Object):Sprite
{
/*
creates clickable buttons to change from elements.
*/
var txt:TextField = new TextField();
var gfx:Sprite = new Sprite();
var parent:Sprite = new Sprite();
gfx.graphics.lineStyle(1, 0x222222);
gfx.graphics.drawRect(0, 0, 75, 17);
gfx.graphics.endFill();
gfx.buttonMode = false;
gfx.visible = false;
txt.defaultTextFormat = LetterType("Verdana");
if (e.isFunction) {txt.defaultTextFormat=LetterType("Verdana", 12, true);e.color=0xFFFFFF;}
txt.text = e.name;
txt.width = 100;
txt.height = 17;
txt.textColor = e.color;
txt.selectable = false;
parent.x = x;
parent.y = y;
parent.addChild(gfx);
parent.addChild(txt);
addChild(parent);
parent.addEventListener(MouseEvent.ROLL_OVER, function ():void { gfx.visible = true; });
parent.addEventListener(MouseEvent.ROLL_OUT, function ():void { gfx.visible = false; });
parent.addEventListener(MouseEvent.CLICK, function ():void { elements.type = e; selector.x=x-10; selector.y=y-BOXDOWN;});
return parent;
}
private function FunctionButton(x:Number, y:Number, name:String):Sprite
{
/*
creates clickable buttons to change from elements.
*/
var txt:TextField = new TextField();
var gfx:Sprite = new Sprite();
var parent:Sprite = new Sprite();
gfx.graphics.lineStyle(1, 0x222222);
gfx.graphics.drawRect(0, 0, 100, 17);
gfx.graphics.endFill();
gfx.buttonMode = false;
gfx.visible = false;
txt.defaultTextFormat = LetterType("Verdana");
txt.defaultTextFormat=LetterType("Verdana", 12, true);
txt.text = name;
txt.width = 100;
txt.height = 17;
txt.textColor = 0xFFFFFF;
txt.selectable = false;
parent.x = x;
parent.y = y;
parent.addChild(gfx);
parent.addChild(txt);
addChild(parent);
parent.addEventListener(MouseEvent.ROLL_OVER, function ():void { gfx.visible = true; });
parent.addEventListener(MouseEvent.ROLL_OUT, function ():void { gfx.visible = false; });
return parent;
}
private function LetterType(myfont:String, size:Number=12, bold:Boolean=false, underline:Boolean=false):TextFormat
{
/*
modifies the lettertype from a textfield.
*/
var format:TextFormat = new TextFormat();
format.font = myfont;
format.size = size;
format.bold = bold;
format.underline = underline;
return format;
}
private function mainframe():TextField
{
/*
creates a textfield for debugging (mainframe).
*/
var mainframe:TextField = new TextField();
mainframe.x = 10;
mainframe.y = 0;
mainframe.width = BOXRIGHT;
mainframe.height = 60;
mainframe.textColor = 0xFFFFFF;
mainframe.selectable = false;
addChild(mainframe);
return mainframe;
}
}
}
class Dot
{
/* the name to be displayed */
public var name:String = "blanco";
/* determines its weight and thus it has direct influence in its physics */
public var mass:Number = 0;
/* determines the color of the element */
public var color:uint = 0x000000;
/* determines whether the element can move its x-axis. */
/* soon deprecated and replaced by liquid / gas. */
public var movable:int = 0;
/* determines whether the element is flammable. */
/* flammable elements ignites on eachother. */
public var flammable:int = 0;
/* determines whether it can ignites objects. */
public var ignites:Boolean = false;
/* determines whether the element decays. */
public var decay:int = 0;
/* assigns a customscript to the element. */
public var customScript:Function=null;
/* determines it is a specific function. */
public var isFunction:Boolean=false;
/* allows the element to be pulled or not. */
public var allowPull:Boolean=true;
}
class Elements
{
public var type:Object = Sand();
public var elementType:Array = new Array();
public function Elements():void
{
this.elementType.push(Stone());
this.elementType.push(Sand());
this.elementType.push(Water());
this.elementType.push(Methane());
this.elementType.push(Fire());
this.elementType.push(Iron());
this.elementType.push(Dynamite());
this.elementType.push(Lava());
this.elementType.push(Rust());
this.elementType.push(Steam());
this.elementType.push(Ice());
this.elementType.push(Wall());
this.elementType.push(Wood());
this.elementType.push(Plant());
this.elementType.push(Branch());
this.elementType.push(Seed());
this.elementType.push(Human());
this.elementType.push(Ufo());
this.elementType.push(Cloud());
this.elementType.push(Laser());
this.elementType.push(Torch());
this.elementType.push(Slime());
this.elementType.push(Glue());
this.elementType.push(_Erase());
this.elementType.push(_Drag());
}
public function getType():Object
{
return type;
}
public function resetType():void
{
type=Sand();
}
public function getElementByColor(color:uint):Object
{
for each (var element:Object in elementType)
{
if (element.color == color)
{
return element;
}
}
return false;
}
public function Methane():Dot
{
var dot:Dot = new Dot();
dot.name = "Methane";
dot.color = 0x112211; //0x556655;
dot.mass = -1;
dot.movable = 5;
dot.flammable = 7;
return dot;
}
public function Water():Dot
{
var dot:Dot = new Dot();
dot.name = "Water";
dot.color = 0x000088;
dot.mass = 1;
dot.movable = 10;
return dot;
}
public function Stone():Dot
{
var dot:Dot = new Dot();
dot.name = "Stone";
dot.color = 0x555555;
dot.mass = 4;
return dot;
}
public function Sand():Dot
{
var dot:Dot = new Dot();
dot.name = "Sand";
dot.color = 0xFFCC66;
dot.mass = 2;
return dot;
}
public function Fire():Dot
{
var dot:Dot = new Dot();
dot.name = "Fire";
dot.color = 0xFF0000;
dot.mass = -1;
dot.ignites = true;
dot.decay = 2;
return dot;
}
public function Iron():Dot
{
var dot:Dot = new Dot();
dot.name = "Iron";
dot.color = 0x333333;
return dot;
}
public function Dynamite():Dot
{
var dot:Dot = new Dot();
dot.name = "Dynamite";
dot.color = 0xCC0000;
dot.flammable = 10;
return dot;
}
public function Lava():Dot
{
var dot:Dot = new Dot();
dot.name = "Lava";
dot.color = 0xCC3300;
dot.mass = 1;
dot.ignites = true;
dot.movable = 8;
return dot;
}
public function Rust():Dot
{
var dot:Dot = new Dot();
dot.name = "Rust";
dot.color = 0x660000;
dot.mass = 2;
return dot;
}
public function Steam():Dot
{
var dot:Dot = new Dot();
dot.name = "Steam";
dot.mass = -1;
dot.color = 0xFFFFFF;
dot.decay = 9;
return dot;
}
public function Ice():Dot
{
var dot:Dot = new Dot();
dot.name = "Ice";
dot.color = 0xBBBBFF;
return dot;
}
public function Wood():Dot
{
var dot:Dot = new Dot();
dot.name = "Wood";
dot.color = 0x663300;
dot.flammable = 6;
return dot;
}
public function Plant():Dot
{
var dot:Dot = new Dot();
dot.name = "Plant";
dot.color = 0x006600;
dot.flammable = 7;
dot.mass = 0;
return dot;
}
public function Branch():Dot
{
var dot:Dot = new Dot();
dot.name = "Branch";
dot.color = 0x663301;
dot.flammable = 7;
dot.mass = 0;
return dot;
}
public function Seed():Dot
{
var dot:Dot = new Dot();
dot.name = "Seed";
dot.color = 0x66FF33;
dot.flammable = 4;
return dot;
}
public function Wall():Dot
{
var dot:Dot = new Dot();
dot.name = "Wall";
dot.color = 0xEEEEAA;
dot.allowPull = false;
return dot;
}
public function Human():Dot
{
var dot:Dot = new Dot();
dot.name = "Human";
dot.color = 0xFF6699;
dot.flammable = 9;
dot.movable = 1;
dot.mass = 1;
return dot;
}
public function Ufo():Dot
{
var dot:Dot = new Dot();
dot.name = "Ufo";
dot.color = 0x00CCCC; //0x556655;
dot.mass = -2;
dot.movable = 2;
dot.flammable = 1;
return dot;
}
public function Cloud():Dot
{
var dot:Dot = new Dot();
dot.name = "Cloud";
dot.color = 0x999999; //0x556655;
dot.mass = -2;
dot.movable = 1;
return dot;
}
public function Laser():Dot
{
var dot:Dot = new Dot();
dot.name = "Laser";
dot.color = 0x00FF00; //0x556655;
dot.ignites = true;
dot.mass = 5;
dot.decay = 3;
return dot;
}
public function Torch():Dot
{
var dot:Dot = new Dot();
dot.name = "Torch";
dot.color = 0xFF6600;
dot.mass = 2;
return dot;
}
public function Glue():Dot
{
var dot:Dot = new Dot();
dot.name = "Glue";
dot.color = 0xDDDDDD;
dot.mass = 1;
return dot;
}
public function Slime():Dot
{
var dot:Dot = new Dot();
dot.name = "Slime";
dot.color = 0x99FF33;
dot.mass = 3;
dot.movable = 2;
return dot;
}
/*
Function buttons.
*/
public function _Erase():Dot
{
var dot:Dot = new Dot();
dot.isFunction = true;
dot.name = "Erase";
return dot;
}
public function _Drag():Dot
{
var dot:Dot = new Dot();
dot.isFunction = true;
dot.name = "Pull";
return dot;
}
public function _Size():Dot
{
var dot:Dot = new Dot();
dot.isFunction = true;
dot.name = "Size";
return dot;
}
public function _Save():Dot
{
var dot:Dot = new Dot();
dot.isFunction = true;
dot.name = "Save";
return dot;
}
public function _Load():Dot
{
var dot:Dot = new Dot();
dot.isFunction = true;
dot.name = "Load";
return dot;
}
}