Пример #1
0
 public void tick() {
   Grid help = new Grid(size);
   int i = 0, j = 0;
   for (; i < size; i++) {
     for (j = 0; j < size; j++) {
       if (grid[i][j].getState().equals("*")) {
         if (count(i, j) == 2 || count(i, j) == 3) {
           help.getGrid()[i][j].setState("*");
         } else {
           help.getGrid()[i][j].setState("-");
         }
       } else {
         if (count(i, j) == 3) {
           help.getGrid()[i][j].setState("*");
         } else {
           help.getGrid()[i][j].setState("-");
         }
       }
     }
   }
   for (i = 0; i < size; i++) {
     for (j = 0; j < size; j++) {
       grid[i][j].setState(help.getGrid()[i][j].getState());
     }
   }
 }
Пример #2
0
  /** Paints the grid, the falling shape and the next shape */
  public void paintComponent(Graphics g) {

    super.paintComponent(g);

    grid.drawGrid(grid.getGrid(), g);
    game.getCurrentShape().drawShape(g);
    game.drawAllShapes(g, game.getAllShapes());

    repaint();
  }