wechat weapp 2048
1.0.0
The main difficulty of this program is that when the user slides the screen, cells with the same value are merged and the spaces are marked as 0 ("" is used in my code to represent spaces). Assume that the chessboard is as follows:
item[0] = [2, 0, 2, 0]; item[1] = [0, 0, 0, 0]; item[2] = [2, 0, 0, 0]; // Note that it is 2000 Instead of 0002, because sliding to the right starts from the right item[3] = [0, 0, 0, 0];
- Move all 0s in item[0] to the end to become 2200, traverse the items and add the same subscript values, and set the following numbers to 0
- 2020 ---> 2200 ---> 4200 ----> 4000