Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

Monday, November 17, 2008

LittleBigPlanet [Game]

LittleBigPlanet is a very cool game for the PS3 that allows you to create your own levels. It's like the power of robotic lego's at your fingertips.

I would have never known how cool this game if I didn't have someone show it to me because it takes about 8 hours of playing till you have enough status to really start making anything. Essentially you can make anything out of switches, pistons, motors, shapes, springs etc... It's like a fantasy sandbox of cool capabilities. All this is wrapped up in a nice sonic / visual package that effortlessly reflects the style of Michele Gondry. The videos below highlight some unique uses of the tools.

Last night I went out and bought a PS3, just so I could play this game :)

Gradius (Side-scrolling shooter):


How to make a gravity defying car:


How to make an OR Switch:


Calculator (LittleBigComputer)


Little Big Planet - Playstation 3

Friday, July 18, 2008

Code: Linear Transform

AS3 code that calculates a mathematical linear transformation on a value given a min and max for the original scale and the min and max for the target scale. I use this on nearly every project. Thanks to David Bliss of Odopod for writing the code.

Example:
var sourceValue = 50;
var minSource = 0;
var maxSource = 100;
var minTarget = 0;
var maxTarget = 200;
targetValue = linearTrans(sourceValue, minSource, maxSource, minTarget, maxTarget);


Returns targetValue: Number between minTarget and maxTarget = 100

Function:
public static function linearTrans(sourceValue:Number, minSource:Number, maxSource:Number, minTarget:Number, maxTarget:Number):Number {
if (minTarget
var range = Math.abs(maxTarget - minTarget);
var direction = 1;
} else {
var range = Math.abs(minTarget - maxTarget);
var direction =- 1;
}

var sourceRange = maxSource - minSource;

var progress=(sourceValue-minSource)/(sourceRange);
progress=Math.max(Math.min(1, progress), 0);
// now progress is between 0 and 1

progress *= direction * range;
progress = progress + minTarget;

return(progress);
}

Tuesday, April 8, 2008

Colors of Code



A pleasant color scheme called "Zenburn" used for writing code or whatever text you stare at all day.

Get it »

Tuesday, March 25, 2008

Code: The difference between multidimensional vectors

I often forget the formula for finding the difference between two multidimensional vectors. So here it is for you and me in Flash ActionScript :)

//=====================================================
// vector a
ax = 6;
ay = 2;
az = 3;

// vector b
bx = 7;
by = 2;
bz = 4;

// number of axis in each vectors
axis = 3;

// calculate difference between vector a and b
diff = Math.abs(( (ax - bx) + (ay - by) + (az - bz) ) / axis);

// output result
trace( diff );

// trace output: 0.666666666666667