PDA

View Full Version : puzzle help


vilehelm
12-14-2001, 10:30 PM
Howdy all, Trying to put together an example for a client of an adver-game. Simple game simple message anyway...

i used a standard sample file in the flash 5 samples folder and made a few modifications. it's the sliding piece puzzle game and the only thing that fails on it is the movie clip labeled "p0". for some reason it's dead wherever it lands after the shuffle.

this is just something that i wanted to whip-out and say "see this is sort of what i'm talking about"per usual the flash snake has bitten me in the ass.

http://www.westwayne.com/interactive/experiment/Puzzle2.swf
http://www.westwayne.com/interactive/experiment/Puzzle2.fla

the only real changes that i made was disabling the routine that dynamically generated the "tiles" and instead made my own pictographic tiles with the instance names already in place.

Any thoughts or insight to this dead tile would be greatly appreciated.

20 Ton Squirrel
12-14-2001, 11:40 PM
VILE! Werd, dawg. I dun checked out your file and saw the problem RIGHT OFF THE BAT.

Your Initialize function assigns your pieces a variable PieceNumber which increments from 1 to however many there are.

Checking the Debugger, I found that your first piece wasn't being assigned a PieceNumber. So... THAT is why it isn't moving... because your function Click specifically calls for that variable.

I tweaked your code a bit and got it working JUST fine. Check it out, my friend...

// Subroutine Initialize
// Puzzle Initialization Code
function Initialize () {
Congratulations.stop();
// Set dimensions of game grid
numRows = 4;
numCols = 4;
numCells = numRows*numCols;
xBase = p0._x;
yBase = p0._y;
xSpace = p0._width*1.03;
ySpace = p0._height*1.03;
// Create pieces
var c = 0; //CHANGED THIS TO GET COLUMNS RIGHT (20TS 12/14/01)
var r = 0;
//CHANGED LOOP TO START AT 0 INSTEAD OF 1 (20TS 12/14/01)
for (var i = 0; i<numCells-1; i++) {
var name = "p"+i;
var newPiece = eval(name);
newPiece._x = PieceX(c);
newPiece._y = PieceY(r);
newPiece.PieceNumber = i+1;
if (++c>=numCols) {
c = 0;
r++;
}
}
// Set initial positions of each cell, including empty space
posArray = [];
for (i=0; i<numCells-1; i++) {
posArray[i] = i;
}
empty = numCells-1;
}


Aawwwwww yeah... damn it feels good ta be a gangsta...

vilehelm
12-15-2001, 01:56 AM
If i could get my arms all the way around i'd hug ya...oh well

thanks buddy

onewong
02-06-2006, 08:51 AM
can someone help me in creating the sliding-puzzle game in the flash?:)