Hi
I'm new to Java i'm looking at a tetris game code and trying to define every line get an understanding of what actually happens, I've tried putting breakpoints but they just lead me to source code.
enum tetrodd{NoShape, ZShape, SShape, LineShape,
TShape, SquareShape, LShape, MirroredLShape };
private tetrodd pieceShape;
private int coords[][];
private int [][][] coordsTable;
public Shape(){
coords = new int [4][2];
setShape (tetrodd.NoShape);
}
public void setShape(tetrodd shape){
coordsTable = new int[][][] {
{ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
{ { 0, -1 }, { 0, 0 }, { -1, 0 }, { -1, 1 } },
{ { 0, -1 }, { 0, 0 }, { 1, 0 }, { 1, 1 } },
{ { 0, -1 }, { 0, 0 }, { 0, 1 }, { 0, 2 } },
{ { -1, 0 }, { 0, 0 }, { 1, 0 }, { 0, 1 } },
{ { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } },
{ { -1, -1 }, { 0, -1 }, { 0, 0 }, { 0, 1 } },
{ { 1, -1 }, { 0, -1 }, { 0, 0 }, { 0, 1 } }};
for (int i = 0; i< 4; i++){
for (int j = 0; j<2; ++j){
coords[i][j] = coordsTable[shape.ordinal()][i][j];
}
}
pieceShape = shape;
}
I'm trying to figure out what happens at the line;
coords[i][j] = coordsTable[shape.ordinal()][i][j];
what values gets stored on coords whats the actual value of [shape.ordinal()]
Thanks for your time.
Regards.