MCPcopy Create free account
hub / github.com/TanaStudy/Java-Study / canFall

Method canFall

8. Demo/Java/src/main/LeetCode/Tetris/Main.java:134–149  ·  view source on GitHub ↗
(int m, int n)

Source from the content-addressed store, hash-verified

132 }
133 /*判断正下落的方块是否可以下落*/
134 public boolean canFall(int m, int n) {
135 int temp = 0x8000;//表示1000 0000 0000 0000
136 for (int i = 0; i < 4; i++) {//循环遍历16个方格(4*4)
137 for (int j = 0; j < 4; j++) {
138 if ((temp & rect) != 0) {// 此处有方块时
139 if (data[m + 1][n] == 1)// 如果下一个地方有方块,则直接返回false
140 return false;
141 }
142 n++;//列加一
143 temp >>= 1;
144 }
145 m++;// 下一行
146 n = n - 4;// 回到首列
147 }
148 return true;//可以掉落返回true
149 }
150 /*把不可下降的方块的对应的data存储为1,表示此坐标有方块*/
151 public void saveData(int m, int n) {
152 int temp = 0x8000;//表示1000 0000 0000 0000

Callers 2

startMethod · 0.95
keyTypedMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected