Java 俄罗斯方块消行算法
2020-08-12 11:02
阅读数 9
/** * 消行得分 */ private int plusExp() { //获取地图信息 boolean[][] gameMap =
this.gameDto.getGameMap(); //初始化消行数 int lineNum=0; //扫描地图,判断是否可以消行 for(int
y=0;y
this.removeLine(y,gameMap); //增加消行数 lineNum++; } } return lineNum; } /** * 消行操作
*/ private void removeLine(int rowNumber,boolean[][] gameMap){ for(int
x=0;x
y=rowNumber;y>0;y--){ gameMap[y][x]=gameMap[y-1][x]; } //第0行置为false
gameMap[0][x]=false; } } /** * 判断是否可以消行 */ private boolean isCanRemoveLine(int
y,boolean[][] gameMap) { for(int
x=0;x
if(!gameMap[y][x]){ return false; } } return true; }