Page 873 - 2
P. 873

final int BoardHeight = 22;
                public int speed=400;
                Timer timer;
                boolean isFallingFinished = false;
                boolean isStarted = false;
                boolean isPaused = false;
                int numLinesRemoved = 0;
                int curX = 0;
                int curY = 0;
                JLabel statusbar;
                JLabel statusbar1;
                Shape curPiece;
                Tetrominoes[] board;


                public Board(Tetris parent) {
                   setFocusable(true);
                   curPiece = new Shape();
                   timer = new Timer(speed, this);
                   timer.start();


                   statusbar = parent.getStatusBar();
                   statusbar1 = parent.getStatusBar1();
                   board = new Tetrominoes[BoardWidth * BoardHeight];
                   addKeyListener(new TAdapter());
                   clearBoard();
                }


                public void actionPerformed(ActionEvent e) {
                    if (isFallingFinished) {
                        isFallingFinished = false;
                        newPiece();
                    } else {
                        oneLineDown();
                    }
                }


                int squareWidth() { return (int) getSize().getWidth() / BoardWidth; }
                int squareHeight() { return (int) getSize().getHeight() / BoardHeight; }
                Tetrominoes shapeAt(int x, int y) { return board[(y * BoardWidth) + x]; }


                public void start()
                {
                    if (isPaused)
                        return;




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