There are more off course, but theses are the one I know there needs to be some more work to be done one currently.
A tile can only merge once per turn.
On a player move. Do the following.
On move up (e.g.)
- Start from the top cell.
- Check if cell has a tile. If empty, store that fact and move to next cell.
- Find incoming tile It may stop before current cell, merge into or take its place. If there is no incoming tile.
Continue to next cell. - Check if incoming tile has equal value. If so merge with curren tile.
If current cell is empty, move incoming tile here.- If previous cell was empty, move current tile there. Store that current cell is empty.
- Go back to step 2.
let testColumn1 = [null,2,2,null]
should result to:
[4,null,null,null]
let testColumn2 = [2,2,2,null]
should result to:
[4,2,null,null]
let testColumn3 = [2,2,2,2]
should result to:
[4,4,null,null]