Hi,
i just wrote code to create puzzlepieces on the fly, and while I am not
allowed to give out code, I can tell you how I did it. It only answers the
'infamous jigsaw pattern' though, not the bitmap part.

-I drew one side using a simpledrawing app written in flash, like mousedown
is an anchor point and you click enough times to draw one side of the puzzle
piece. Pressing space gave me back the point data.
-To actually draw a fluid line through the points, I used the principe of
curveTo's with the averaged anchor points
-once you have the data to draw one side, you can scale, flip, rotate, move
it etc to create nubbins, cutouts, flatsides and on everyside, all the way
around until you have a solid puzzle piece, usable as a mask.
-you can even use the simpledrawing app to draw a few different sides, to
make it more interesting, so you have a sidetype 1 and a sidetype 2 for
example, or you could use the basic data you had from step one, and
autogenerate variations, by adding some random offset to each point.
-create the random puzzle comes down to matches the sidetypes, and inverting
the nubbins, cutouts..

Im sorry I can't help you out further, but I hope at least this part was
helpfull.

greetz
Hans





On 7/6/06, Adrian Lynch <[EMAIL PROTECTED]> wrote:

This was done a while back, but having it uniform doesn't work too well:

http://www.halestorm.co.uk/jigsaw/

The innie-outie bit's are done randomly and it looks ok, but I was hoping
to
find something that would  cut it more like a regular jigsaw.

Let us know if you find anything.

Adrian

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Peter
Hall
Sent: 06 July 2006 04:09
To: Flashcoders mailing list
Subject: Re: [Flashcoders] jigsaw puzzle piece algorithm


The optimal way is probably to use copyPixels() for each puzzle piece,
setting the alphaBitmapData argument to an image that contains just
the puzzle piece shape. That will effectively mask out the shape of
the piece, but will perform a lot better than using a vector mask, as
it will have modified the image, rather than apply the mask each time
the screen area gets redrawn.

Jigsaw puzzle pieces are likely quite small as vector graphics, so you
might want to keep them as vector assets and then create the
alphaBitmapData objects at runtime, as you need them.

If you really want to generate the shape pieces dynamically, you could
divide the image into rectangles (or randomly varying quadrilaterals,
to keep it interesting), then have a selection of nobbly bits you
could randomly choose to add or remove from each side of the pieces.
Having someone draw these by hand seems like less hassle though -
unless you need to create a lot of puzzles...

Peter


On 7/6/06, Guntur N. Sarwohadi <[EMAIL PROTECTED]> wrote:
> I'm working on a puzzle game in flash, much similar to jigsaw puzzles
you
> see in gameHouse or such casual game publisher. I'm having a hard time
> trying to cut an image to make it as puzzle pieces in AS2. Currently I'm
> doing it the hard way, cloning bitmapData image, and masking portions of
the
> image. Can you cut parts on an image using bitmapData methods? And does
> anyone know how to create the infamous jigsaw pattern to it as well?
>
> Many thanks,
> Guntur N. Sarwohadi

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to