Skip to content

Commit

Permalink
cleanup repeat logic in determineCurrentTetrimino switch
Browse files Browse the repository at this point in the history
  • Loading branch information
rystills committed Mar 16, 2019
1 parent 0779c68 commit faa9aff
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/TSpinTutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,44 +205,32 @@ public static void determineCurrentTetrimino() {
for (int y = 0; y <= gridBot-gridTop && curShadowCol <= 3; y += bSize) {
switch (capture.getRGB(x,y)) {
case -8335379: //I block
curBlock = Tetrimino.I;
shadowRows[curShadowCol] = y/bSize;
shadowCols[curShadowCol++] = x/bSize;

curBlock = Tetrimino.I;
break;
case -6784: //O block
curBlock = Tetrimino.O;
shadowRows[curShadowCol] = y/bSize;
shadowCols[curShadowCol++] = x/bSize;
break;
case -3500340: //T block
curBlock = Tetrimino.T;
shadowRows[curShadowCol] = y/bSize;
shadowCols[curShadowCol++] = x/bSize;
break;
case -4923500: //S block
curBlock = Tetrimino.S;
shadowRows[curShadowCol] = y/bSize;
shadowCols[curShadowCol++] = x/bSize;
break;
case -617316: //Z block
curBlock = Tetrimino.Z;
shadowRows[curShadowCol] = y/bSize;
shadowCols[curShadowCol++] = x/bSize;
break;
case -8342818: //J block
curBlock = Tetrimino.J;
shadowRows[curShadowCol] = y/bSize;
shadowCols[curShadowCol++] = x/bSize;
break;
case -17280: //L block
curBlock = Tetrimino.L;
shadowRows[curShadowCol] = y/bSize;
shadowCols[curShadowCol++] = x/bSize;
break;
default: //no block color detected
break;
continue;
}
//add the detected block to the shadow position arrays
shadowRows[curShadowCol] = y/bSize;
shadowCols[curShadowCol++] = x/bSize;
}
}
}
Expand Down

0 comments on commit faa9aff

Please sign in to comment.