Игру валидатор мне закрыл, все прошел, но количество очков выводит только после окончания игры. речь о setScore() -ниже помечены места. Вообще ощущение неправильной работы движка, куда уже только не кидал я эту логику ! И com.javarush.engine.cell нельзя редактировать его классы... Думал посмотреть как работает класс Game.class, но внутри ничего не поправить... package com.javarush.task.jdk13.task53.task5301; import com.javarush.engine.cell.*; import java.sql.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class Game2048 extends Game { private static final int SIDE = 4; private int[][] gameField = new int[SIDE][SIDE]; private boolean isGameStopped = false; private int score; // _______________________________________________________ВОТ ТУТ private void createNewNumber() { if (getMaxTileValue() == 2048) { win(); } int y, x; do { x = getRandomNumber(SIDE); y = getRandomNumber(SIDE); } while (gameField[x][y] != 0); gameField[x][y] = getRandomNumber(10) < 9 ? 2 : 4; } private void createGame() { gameField = new int[SIDE][SIDE]; createNewNumber(); createNewNumber(); } private void drawScene() { // gameField= new int[][]{ {2,4,8,16}, {32,64,128,256}, {512,1024,2048,0}, {2,4,8,16} }; for (int x = 0; x < gameField.length; x++) { for (int y = 0; y < gameField[x].length; y++) { setCellColoredNumber(x, y, gameField[y][x]); } } } private void setCellColoredNumber(int x, int y, int value) { Color color = getColorByValue(value); if (value == 0) { setCellValueEx(x, y, color, ""); } else { setCellValueEx(x, y, color, String.valueOf(value)); } } private Color getColorByValue(int value) { var color = switch (value) { case 0 -> { yield Color.CYAN; } case 2 -> { yield Color.AQUA; } case 4 -> { yield Color.ALICEBLUE; } case 8 -> { yield Color.AZURE; } case 16 -> { yield Color.BLUEVIOLET; } case 32 -> { yield Color.BISQUE; } case 64 -> { yield Color.BLANCHEDALMOND; } case 128 -> { yield Color.BURLYWOOD; } case 256 -> { yield Color.CADETBLUE; } case 512 -> { yield Color.RED; } case 1024 -> { yield Color.BLUE; } case 2048 -> { yield Color.CRIMSON; } default -> { yield Color.BLACK; } }; return color; } private boolean compressRow(int[] row) { boolean a = false; List<Integer> list = new ArrayList<>(); for (Integer x : row) { if (x != 0) { list.add(x); } } while (list.size() != row.length) { list.add(0); } for (int i = 0; i < row.length; i++) { if (row[i] != list.get(i)) { row[i] = list.get(i); a = true; } } return a; } private boolean mergeRow(int[] row) { int[] row2 = row.clone(); for (int i = 0; i < row.length - 1; i++) { if (row[i] == row[i + 1]) { row[i] = row[i] * 2; score += row[i]; // _______________________________________________________ВОТ ТУТ setScore(score); System.out.println(score); row[i + 1] = 0; } } return !Arrays.equals(row2, row); } private void moveLeft() { boolean a = false; for (int[] x : gameField) { if (compressRow(x) | mergeRow(x)) { a = true; } compressRow(x); } if (a) { createNewNumber(); } } private void moveRight() { rotateClockwise(); rotateClockwise(); moveLeft(); rotateClockwise(); rotateClockwise(); } private void moveDown() { rotateClockwise(); moveLeft(); rotateClockwise(); rotateClockwise(); rotateClockwise(); } private void moveUp() { rotateClockwise(); rotateClockwise(); rotateClockwise(); moveLeft(); rotateClockwise(); } private int getMaxTileValue() { int max = 0; for (int[] x : gameField) { for (int y : x) { if (y > max) { max = y; } } } return max; } @Override public void onKeyPress(Key key) { if (isGameStopped) { if (key.equals(Key.SPACE)) { isGameStopped = false; createGame(); score = 0; // _______________________________________________________ВОТ ТУТ setScore(score); drawScene(); } } if (isGameStopped & !key.equals(Key.SPACE)) { return; } if (!canUserMove()) { gameOver(); return; } if (key.equals(Key.UP)) { moveUp(); drawScene(); } if (key.equals(Key.DOWN)) { moveDown(); drawScene(); } if (key.equals(Key.LEFT)) { moveLeft(); drawScene(); } if (key.equals(Key.RIGHT)) { moveRight(); drawScene(); } } private void rotateClockwise() { int[][] row = new int[gameField.length][gameField[0].length]; for (int i = 0; i < gameField.length; i++) { for (int j = 0; j < gameField[i].length; j++) { row[i][j] = gameField[i][j]; } } for (int i = 0; i < gameField.length; i++) { for (int j = 0; j < gameField[i].length; j++) { gameField[i][j] = row[row.length - j - 1][i]; } } } private boolean canUserMove() { for (int[] x : gameField) { for (int y : x) { if (y == 0) { return true; } } } for (int i = 0; i < gameField.length; i++) { for (int j = 0; j < gameField[j].length - 1; j++) { if (gameField[i][j] == gameField[i][j + 1]) { return true; } } } rotateClockwise(); for (int i = 0; i < gameField.length; i++) { for (int j = 0; j < gameField[j].length - 1; j++) { if (gameField[i][j] == gameField[i][j + 1]) { rotateClockwise(); rotateClockwise(); rotateClockwise(); return true; } } } rotateClockwise(); rotateClockwise(); rotateClockwise(); return false; } private void win() { showMessageDialog(Color.DARKGRAY, "YOU ARE WINNER!", Color.GOLD, 12); isGameStopped = true; } private void gameOver() { showMessageDialog(Color.DARKGRAY, "GAME OVER", Color.GOLD, 12); isGameStopped = true; } @Override public void initialize() { setScreenSize(SIDE, SIDE); createGame(); drawScene(); } }