Recently I’ve been experimenting with different types of random games; generally small tile based stuff like the old classic phone game- snake. I’m still in the process of finishing one (will post the source here when I do) but generally I’ve enjoyed the process, especially the way tiles are so predictable. You can test for certain conditions with tiles as you know the player can only move or hit certain coordinates constrained by the size of the tiles. Anyway after all this messing about with squares I started playing with Flash’s perlin noise to generate random shapes and got some interesting results. I really like the fluidity you get from perlin noise which is in real contrast to the games I have been experimenting with recently. Also these techniques can be applied to make platform games to generate random levels.

In theory you can generate a block of random perlin noise by using a random number to define the 'random seed' argument of the noise constructor. You can then take a cross section (i.e. a row of pixels) from the block and, depending on how bright or dark that pixel is, you can position your shape or line according to the pixel’s value.
The possibilities of this technique are endless.. (animating noise, moving objects around depending on the pixels darkness etc) and I will definitely be playing with noise some more in the future. For now I’ve posted a quick example of how to use this process to create a random platform landscape, quickly and cleanly.
package
{
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
/**
* @author Dan Bennett
* @email dan.bennett86@yahoo.com
*/
[SWF(width="900", height="700", backgroundColor="#ffffff")]
public class PerlinNoisePlatform extends Sprite
{
private static const BOX_WIDTH:int = 100;
private static const BOX_HEIGHT:int = 100;
private static const RANGE:int = 300;
private var xPos:Number = 1;
private var darkness:Number = 1;
public function PerlinNoisePlatform()
{
var noise:BitmapData = createNoise();
drawPlatform(noise);
}
private function createNoise():BitmapData
{
var randomSeed:int = Math.random() * 100;
var contents:BitmapData = new BitmapData(BOX_WIDTH, BOX_HEIGHT);
contents.perlinNoise(BOX_WIDTH, BOX_HEIGHT,6,randomSeed,false,false,7,true);
return contents;
}
private function drawPlatform(data:BitmapData):void
{
// Pick a starting point to get our row of pixels
var xStart:Number = Math.floor(Math.random() * BOX_WIDTH);
for(var i:int = 0;i<BOX_HEIGHT;i++)
{
var shape:Shape = new Shape();
shape.graphics.moveTo(xPos, darkness * RANGE);
if(i % 4 == 0)
{
this.darkness = data.getPixel( xStart , i) / 0xFFFFFF;
}
this.xPos+=10;
shape.graphics.lineStyle(1,0x000000);
shape.graphics.lineTo(xPos, darkness * RANGE);
this.addChild(shape);
}
}
}
}