Author Archives: Zevan

QuickBox2D Documentation

I finally finished the QuickBox2D documentation. Check it out here.
You can download QuickBox2D and see a few example code snippets on the QuickBox2D page. Should have a tutorial on that page in the next couple of days.

Posted in Box2D, QuickBox2D, motion | Tagged , | 5 Comments

Instantiate and Set Properties

CLICK HERE TO COPY
Actionscript:

function create(obj:Class, props:Object):*{

    var o:* = new obj();

    for (var p:String in props){

        o[p] = props[p];

    }

    return o;

}

 

// test out the function

 

var txt:TextField = create(TextField, {x:200, y:100, selectable:false, text:"hello there", textColor:0xFF0000, defaultTextFormat:new TextFormat("_sans", 20)});

addChild(txt);

 

var s:Sprite = Sprite(addChild(create(Sprite, {x:100, y:100, rotation:45, alpha:.5})));

 

with (s.graphics) beginFill(0xFF0000), drawRect(-20,-20,40,40);

 

var [...]

Posted in dynamic, functions, one-liners, properties | Tagged , | Comments closed

Messy Code

CLICK HERE TO COPY
Actionscript:

var xp:Number=0,yp:Number=0;

var r:Number=0,t:Number=0;

var speed:Number=.01;

var scale:Number=10;

var shape:Shape = Shape(addChild(new Shape()));

shape.x=stage.stageWidth/2;

shape.y=stage.stageHeight/2;

shape.graphics.lineStyle(0,0x000000);

 

var s:Number=100;

var range:Number=.2;

var b:Number=20;

var a:Number =b*range;

 

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {

    range=.2;

    b=20;

    a=b*range;

    t=0;

    shape.graphics.clear();

    shape.graphics.lineStyle(0,0);

    for (var i:int = 0; i<6000; i++) {

        var sin:Number=Math.cos(t*int(mouseY/20));

        r =  Math.sqrt(40 * b * [...]

Posted in misc | Tagged , | Leave a comment

Distance Render

CLICK HERE TO COPY
Actionscript:

var verts:Vector.<Number> = new Vector.<Number>();

var pVerts:Vector.<Number> = new Vector.<Number>();

var uvts:Vector.<Number> = new Vector.<Number>();

 

var hs:Number = 2.3;

var step:Number = 0.04;

 

var tVerts:Vector.<Number> = new Vector.<Number>();

var rVerts:Vector.<Number> = new Vector.<Number>();

var matrix:Matrix3D = new Matrix3D();

matrix.identity();

matrix.appendRotation(45,Vector3D.Y_AXIS);

matrix.appendRotation(45,Vector3D.X_AXIS);

var inc:int = 0;

var i:Number, j:Number, k:Number;

i = hs;

while( i> -hs){

    j = hs;

    while(j> -hs){

        k [...]

Posted in BitmapData, Math, Vector, color, graphics algorithms, matrix, pixel manipulation | Tagged , | Leave a comment