PDA

View Full Version : JigSaw Puzzle Problems


mash_potatoe
11-06-2004, 05:25 PM
I am designing a simple jigsaw puzzle game, similar to the Macromedia tutorial, included with the Flash MX program. I am able to create the individual puzzle pieces and I am able to get the pieces to scramble, and i can drag the pieces across the screen, however I cannot get the pieces to snap back together. I know that I need a solution grid, but I do not know what is all needed in order to get the solution grid to work. I have looked at the Macromedia Tutorial solution grid code, but my puzzle has different dimensions and I do not understand what I need to change or include compared to the tutorial code. ANY HELP IS NEEDED!

rtil
11-06-2004, 05:47 PM
you should try cutting & pasting their function and i think the best way to go is to check the X, Y of the top left hand corner of your puzzle and change the numbers like so.

mash_potatoe
11-08-2004, 01:41 PM
Well, I have been looking at their code...but I'll check out my coords. again.

billstoudt
11-08-2004, 04:46 PM
I feel like i might be shooting blind at this so forgive me in advance if i'm
totally off base.


i would first in a frame behind a solid color(essentially obscured from view) have all the puzzel pieces in their completed state then run a for next loop to populate the pieces with thier startX and startY

for(i=1;i<= totalPieces; i++){
// yeah still using eval instead of [] just my preference
eval("piece"+i).startX = eval("piece"+i)._x
eval("piece"+i).startY = eval("piece"+i)._y
}

now that you have thst startX and startY you can scramble the pieces and for all intents and purposes startX and startY are now permanent properties of the pieces that you can check at any time.

if you were more interested in putting that into an array that can be checked instead of cheking movie clip properties you could do that like this.
pieceArray = []
pieceArray[0] = null // so that you can cycle through the array counting at 1 instead of 0
for(i=1;i<= totalPieces; i++){
tempArray = []
tempArray[0] = eval("piece"+i)._x
tempArray[1]= eval("piece"+i)._y
pieceArray.push(tempArray)
}
you now have a 2 dimensionall array that you can access like this.

pieceArray[1][1] woud access the Y location of the first puzzel piece.

I hope this helps and please post if you need more info.

Sincerely...

Bill Stoudt