java吧 关注:1,234,546贴子:12,703,377
  • 2回复贴,共1

帮忙看下我的俄罗斯方块满行删除方法,为嘛一次只能删除1行。。

只看楼主收藏回复

//满行删除方法 void deleteFullLine(){ int full_line_num = 0; int k = 0; for (int i=0;i<rowNum;i++){ boolean isfull = true;
L1:for(int j=0;j<columnNum;j++) if(scrArr[i][j] == 0){ k++; isfull = false; break L1; } if(isfull) full_line_num++; if(k!=0 && k-1!=i && !isfull) for(int j = 0; j < columnNum; j++){ if (scrArr[k][j] == 0) drawUnit(k-1,j,0); else drawUnit(k-1,j,2); scrArr[k-1][j] = scrArr[k][j]; } } for(int i = k-1 ;i < rowNum; i++){ for(int j = 0; j < columnNum; j++){ drawUnit(i,j,0); scrArr[i][j]=0; } } ERS_Block.score += full_line_num; ERS_Block.scoreField.setText(""+ERS_Block.score); }


1楼2013-04-22 12:28回复
    //满行删除方法
    void deleteFullLine(){
    int full_line_num = 0; int k = 0;
    for (int i=0;i<rowNum;i++){
    boolean isfull = true;
    L1:for(int j=0;j<columnNum;j++)
    if(scrArr[i][j] == 0){
    k++; isfull = false;
    break L1; }
    if(isfull) full_line_num++;
    if(k!=0 && k-1!=i && !isfull)
    for(int j = 0; j < columnNum; j++){
    if (scrArr[k][j] == 0) drawUnit(k-1,j,0);
    else drawUnit(k-1,j,2);
    scrArr[k-1][j] = scrArr[k][j]; } }
    for(int i = k-1 ;i < rowNum; i++){
    for(int j = 0; j < columnNum; j++){
    drawUnit(i,j,0);
    scrArr[i][j]=0; } }
    ERS_Block.score += full_line_num;
    ERS_Block.scoreField.setText(""+ERS_Block.score); }


    2楼2013-04-22 12:31
    收起回复