game.js
/* Collapse all empty gaps in the game grid.
 */
Collapse all empty gaps in the game grid.
Collapse all empty gaps in the game grid .
function collapse(game) {
    let w = game.width;
    let h = game.height;
    let g = game.grid;
    for (let x = 0; x < w; x++) {
        for (let y = h - 1; y >= 0; y--) {
            let i = y * w + x;
            if (!g[i])
                gravity(game, x, y);
        }
    }
    for (let x = 0; x < w - 1; x++)
        if (!g[(h - 1) * w + x])
            shift(game, x);
}
function collapse ( game ) { let w = game . width ; let h = game . height ; let g = game . grid ; for ( let x = 0 ; x < w ; x ++ ) { for ( let y = h - 1 ; y >= 0 ; y -- ) { let i = y * w + x ; if ( ! g [ i ] ) gravity ( game , x , y ) ; } } for ( let x = 0 ; x < w - 1 ; x ++ ) if ( ! g [ ( h - 1 ) * w + x ] ) shift ( game , x ) ; }
Collapse all empty gaps in the game grid.
Collapse all empty gaps in the game grid .