Tetris game in java
<p>I'm trying to implement the code for Tetris game, here is the resource I found on Internet <a href="http://zetcode.com/tutorials/javagamestutorial/tetris/" rel="nofollow">http://zetcode.com/tutorials/javagamestutorial/tetris/</a> 
but there are some parts that I can't understand. Can anyone please explain it to me :(</p>

<pre><code>int squareWidth() {
    return (int) getSize().getWidth() / BoardWidth;
}

int squareHeight() {
    return (int) getSize().getHeight() / BoardHeight;
}
</code></pre>

<p>What are those code for? Why it has to /BoardWidth, /BoardHeight</p>

<pre><code>public void paint(Graphics g) {
    super.paint(g);

    Dimension size = getSize();
    int boardTop = (int) size.getHeight() - BoardHeight * squareHeight();


    for (int i = 0; i &lt; BoardHeight; ++i) {
        for (int j = 0; j &lt; BoardWidth; ++j) {
            Tetrominoes shape = shapeAt(j, BoardHeight - i - 1);
            if (shape != Tetrominoes.NoShape) {
                drawSquare(g, 0 + j * squareWidth(),
                        boardTop + i * squareHeight(), shape);
            }
        }
    }

    if (curPiece.getShape() != Tetrominoes.NoShape) {
        for (int i = 0; i &lt; 4; ++i) {
            int x = curX + curPiece.x(i);
            int y = curY - curPiece.y(i);
            drawSquare(g, 0 + x * squareWidth(),
                    boardTop + (BoardHeight - y - 1) * squareHeight(),
                    curPiece.getShape());
        }
    }
}
</code></pre>

<p>For the Paint function, I don't unerstand these algorithm.
Really need help.</p>
