• Home
tudwaythecore.com
blog
  • Recent Posts

    • Detecting focus in flash player
    • BitmapData PerlinNoise
    • Creating bridges in APE part 2
    • Creating bridges in APE
    • SteerWheels 2
    • Creating a simple APE example
    • Design me some levels!
    • Finished Migrating
  • Recent Comments

    • random on Making a Shooting Game Part 2
    • SammyG on Making a Shooting Game Part 2
    • Jim on Making a Shooting Game Part 2
    • rraven on Making a Shooting Game Part 2
    • Adrian on Making a Shooting Game Part 2
  • Categories

    • APE
    • flash
    • game
    • platform
    • sound
    • tutorial
    • Uncategorized
  • Archives

    • May 2009
    • October 2008
    • September 2008
    • August 2008
    • May 2008
    • April 2008
    • March 2008
  •  

    May 2009
    M T W T F S S
    « Oct    
     123
    45678910
    11121314151617
    18192021222324
    25262728293031
  • games

    • Game Showcase
May 26

BitmapData PerlinNoise

flash, game, tutorial Add comments

I haven't posted in a while because i have been busy with other projects, which you will see soon.

I've decided to play with bitmapdata and see what it can be used for. I have used this effect in a game thats in production for the backgrounds because they look quite spacey. And its a quick way to get some awesome looking art without paying an artist.

First an example

Get Adobe Flash player

You should see a blue/green image that looks quite good, something you might find in a game.

PLAIN TEXT
Actionscript:
  1. import flash.display.Bitmap;
  2. import flash.display.BitmapData;
  3.  
  4. var seed:Number=Math.floor(Math.random()*100);
  5. var channels:uint=BitmapDataChannel.BLUE|BitmapDataChannel.GREEN;
  6. var myBitmapDataObject:BitmapData=new BitmapData(550,400,false, 0x00000000);
  7. myBitmapDataObject.perlinNoise(100, 80, 6, seed, false, true, channels, false, null);
  8. var myBitmap:Bitmap=new Bitmap(myBitmapDataObject);
  9. addChild(myBitmap);

Line 1 and 2: Importing the necessary classes needed in this example.

line 4: This is a random number between 1 and 100 that we use when creating the bitmap with perlin noise. This number can be any number but varying it changes the pattern produced.

line 5: Bitmapdata has 4 channels, red blue green and alpha, you can mix channels by using "|". This is what the perlin noise is made up of.

line 6: Creating a black bitmapdata that fills the whole stage. The parameters are : BitmapData(width:int, height:int, transparent:Boolean = true, fillColor:uint = 0xFFFFFFFF)

line 7: Creating a perlin noise over the top of the bitmapdata that we just created. This is what makes those cool effects, play around with the values and see what you get. the parameters are: perlinNoise(baseX:Number, baseY:Number, numOctaves:uint, randomSeed:int, stitch:Boolean, fractalNoise:Boolean, channelOptions:uint = 7, grayScale:Boolean = false, offsets:Array = null).

line 8: Creating the bitmap that will hold the bitmapdata that i created before so that i can display it on stage. You cant add bitmapdata directly to the stage.

line 9: Adding the bitmap to the stage so we can see it.

And thats all for now, i will be experimenting with this later.

Leave a Reply

Powered by WordPress .::. Designed by SiteGround Web Hosting

cssandhtml