Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

Java
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;
Java
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.
Posted
Comments
Richard MacCutchan 15-Mar-13 5:29am    
Breakpoints are supposed to lead you to source code. They stop the program at the breakpoint and allow you to inspect, and possibly change, the value of variables in the program. Assuming you did not write this code yourself you could always contact the author for help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900