Author Archives: Zevan

QuickBox2D FRIM

CLICK HERE TO COPY
Actionscript:

import com.actionsnippet.qbox.*;

import Box2D.Common.Math.*;

 

// try altering your frame rate

[SWF(backgroundColor=0x000000, width=700, height=600, frameRate=30)]

// try setting frim to false

var sim:QuickBox2D = new QuickBox2D(this, {iterations:20, timeStep:1 / 60, frim:true});

 

sim.setDefault({fillColor:0x003366, lineAlpha:0});

sim.createStageWalls();

 

sim.addBox({x:10, y:18, height:3, density:0});

 

sim.setDefault({fillColor:0x004466, lineColor:0x2B80F5});

 

var cVel:b2Vec2 = new b2Vec2();

 

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

    var c:QuickObject = sim.addCircle({x:13 + i % 8, y:10 + int(i [...]

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

QuickBox2D w/ Key Controls

CLICK HERE TO COPY
Actionscript:

import com.actionsnippet.qbox.*;

import Box2D.Common.Math.*

 

[SWF(backgroundColor=0xEFEFEF, width=700, height=600, frameRate=60)]

 

var sim:QuickBox2D = new QuickBox2D(this);

 

sim.setDefault({lineColor:0xCC0000, fillColor:0xCC0000});

 

// create compound shape (two circles and a box for the character)

var charParts:Array = [];

// x and y position are now relative to center of compound shape

charParts[0] = sim.addBox({x:0, y:0, width:1, height:2});

charParts[1] = sim.addCircle({x:0, y:-1, radius:0.5});

charParts[2] = sim.addCircle({x:0, y:1, radius:0.5});

var char:QuickObject = [...]

Posted in Box2D, QuickBox2D, keys, motion | Tagged , , , | 1 Comment

x and y Coordinates in 1D Array / Vector

CLICK HERE TO COPY
Actionscript:

var canvas:BitmapData=new BitmapData(400,400,false,0x000000);

addChild(new Bitmap(canvas));

var pix:Vector.<uint>=canvas.getVector(canvas.rect);

 

canvas.lock();

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

    var xp:int=50+i;

    var yp:int=50+i/2;

    // target x and y coords in 1D array

    pix[xp+yp*400]=0xFFFFFF;

}

canvas.setVector(canvas.rect, pix);

canvas.unlock();

This snippet shows how to target x and y coordinates in a 1D Array / Vector. This can be useful sometimes when [...]

Posted in BitmapData, Vector, arrays, pixel manipulation, setPixel | Tagged , , | Leave a comment

IGraphicsData Example

CLICK HERE TO COPY
Actionscript:

// note the high framerate for testing purposes

[SWF(width = 800, height = 600, frameRate=60)]

// red, yellow, blue

var fills:Vector.<IGraphicsData> = Vector.<IGraphicsData>([new GraphicsSolidFill(0xFF0000),  new GraphicsSolidFill(0xFFCC00), new GraphicsSolidFill(0x0033FF)]);

 

var stroke:IGraphicsData = new GraphicsStroke();

 

var cmds:Vector.<int> = new Vector.<int>();

var ci:int = 0;

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

var di:int = 0;

var igraph:Vector.<IGraphicsData> = new Vector.<IGraphicsData>();

var ig:int  = 0;

var path:Vector.<GraphicsPath> = [...]

Posted in Graphics, Vector, misc, motion | Tagged , , | Leave a comment