Page 874 - 2
P. 874

isStarted = true;
                    isFallingFinished = false;
                    numLinesRemoved = 0;
                    clearBoard();


                    newPiece();
                    timer.start();
                }


                private void pause()
                {
                    if (!isStarted)
                        return;


                    isPaused = !isPaused;
                    if (isPaused) {
                        timer.stop();
                        statusbar.setText("paused");
                    } else {
                        timer.start();
                        statusbar.setText(String.valueOf("score "+numLinesRemoved));
                    }
                    repaint();
                }


                public void paint(Graphics g)
                {
                    super.paint(g);


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


                    for (int i = 0; i < BoardHeight; ++i) {
                        for (int j = 0; j < 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 < 4; ++i) {
                            int x = curX + curPiece.x(i);
                            int y = curY - curPiece.y(i);


                                                         - 874 -
   869   870   871   872   873   874   875   876   877   878   879