/*---------------------------------------------------------- File: puzzle.js Author: Andreas Ravn Version: 0.2 (16.03.2003) Description: Jigsaw puzzle execution program Details: Start by executing function draw_pieces() Still needs these variables to be set from the calling program: var n_x = 5; // number of pieces horiz var n_y = 4; // number of pieces vert var namestem_pieces = "img/pinguin_cellscellXY_"; // var filetype_pieces = ".gif"; // pieces_yx = [ [ [0,0], [0,118], [0,242], [0,366], [0,466]], [ [80,0], [80,94], [80,243], [104,342], [80,491]], [ [214,0], [214,94], [190,218], [214,367], [190,491]], [ [324,0], [300,118], [300,242], [324,366], [300,490]]]; ----------------------------------------------------------*/ // Constants var idstem_pieces = "PIECE_"; // the object ids for pieces always begin with this string var DOCKING_PROX = 5; // the proximity (in pixels) until matching pieces dock var XY_SEP = "_"; // separator for the object x and y parts // Globals var pieces_ids = null; // saves the pieces' div-ids var pieces_inchunk = null; // saves the chunk-id of every piece, or null. var chunks = new Array(); // saves the chunks var ChunkId = 0; // fortlaufende Numerierung der Chunks // --------------------------------------------------------- // install all pieces into internal arrays // --------------------------------------------------------- function installPieces() { linear_piece_counter = 0; pieces_ids = new Array(n_y-1); pieces_images = new Array(n_y-1); pieces_inchunk = new Array(n_y-1); for(var cy=0;cy"); } } }; // --------------------------------------------------------- // change chunk membership of a piece // --------------------------------------------------------- function changeInchunks(from_nr, to_nr) { for(iy=0;iy