kubowania / candy-crush

A vanilla JavaScript Game inspired by Candy Crush
209 stars 264 forks source link

moveDown should be repeated until no more moves BEFORE rescecking for matches #6

Open nstudor opened 3 years ago

nstudor commented 3 years ago

Please check following scenario : image

vinesjames93 commented 2 years ago

hey im pretty new to git hub but i did come up with a method to fix this i believe

when you initiate the board originally do all the checkrow and column functions to set it up then follow up with a function that runs a loop checking for any empty squares in the grid. if theres empty squares run the moveDown function untill every square has a color THEN check matches again and repeat

function run() {

setInterval(function() {

    if (tiles.some(tile => tile.style.backgroundColor === '')) {
    moveDown()
    } else {
        checkRowFour()
        checkColumnFour()
        checkRowThree()
        checkColumnThree()
    }
}
    , 100)

}

start this function directly after the check methods