js/arrangeTiles.js
// Handles the tile click event.
Handles the tile click event.
Handles the tile click event .
function tileClickHandler() {
            if (gridLocked) {
                return false; 
            } else {
                gridLocked = true;
            }
            var el = $(this),
                row = el.data("row"),
                col = el.data("col"),
                blankCoords = grid.getBlankCoords(),
                blankTile,
                gridResult = grid.slideTile(row, col);
            if (gridResult) {
                blankTile = tileCoordsToJQuery(blankCoords[0], blankCoords[1]);
                swapTiles(el, blankTile);
                currentNumMoves++;
                numMoves.text(currentNumMoves.toString());
            } else {
                gridLocked = false;
            }
            if (grid.isSolved()) {
                gameOver();
            }
            if (gameTime.start === 0) {
                runGameTimer();
            }
        }
function tileClickHandler ( ) { if ( gridLocked ) { return false ; } else { gridLocked = true ; } var el = $ ( this ) , row = el . data ( "row" ) , col = el . data ( "col" ) , blankCoords = grid . getBlankCoords ( ) , blankTile , gridResult = grid . slideTile ( row , col ) ; if ( gridResult ) { blankTile = tileCoordsToJQuery ( blankCoords [ 0 ] , blankCoords [ 1 ] ) ; swapTiles ( el , blankTile ) ; currentNumMoves ++ ; numMoves . text ( currentNumMoves . toString ( ) ) ; } else { gridLocked = false ; } if ( grid . isSolved ( ) ) { gameOver ( ) ; } if ( gameTime . start === 0 ) { runGameTimer ( ) ; } }
Handles the tile click event.
Handles the tile click event .
// Check to see if the grid is locked // Locked. Do nothing. // Animate our tile swap // Increment the move number and update the display // Only start the timer when the player's first move has been completed.