Hi. My solution locally looks fine. All full lines are removed and remained not empty are moved down. But I can't still pass the second requirement. Could someone help?
package com.codegym.task.task22.task2213;
import java.awt.event.KeyEvent;
/**
* The Tetris class contains the basic functionality of the game.
*/
public class Tetris {
private Field field; // Game field
private GamePiece gamePiece; // Game piece
private boolean isGameOver; // Indicates whether the game is over
public Tetris(int width, int height) {
field = new Field(width, height);
gamePiece = null;
}
/**
* Getter for the field variable.
*/
public Field getField() {
return field;
}
/**
* Getter for the gamePiece variable.
*/
public GamePiece getGamePiece() {
return gamePiece;
}
/**
* The program's main loop.
* This is where all the important actions happen
*/
public void run() throws Exception {
// Create a KeyboardObserver object and start it.
// KeyboardObserver keyboardObserver = new KeyboardObserver();
// keyboardObserver.start();
// Set the initial value of isGameOver to false
isGameOver = false;
// Create the first game piece in the middle at the top: x = half of the width, y = 0.
gamePiece = GamePieceFactory.createRandomGamePiece(field.getWidth()/2, 0);
// // The game is not over yet
// while (!isGameOver) {
// // Does the observer have any key events?
// if (keyboardObserver.hasKeyEvents()) {
// // Get the first event from the queue
// KeyEvent event = keyboardObserver.getEventFromTop();
// // If 'q', then exit the game.
// if (event.getKeyChar() == 'q') return;
// // If "left arrow", then move the game piece to the left
// if (event.getKeyCode() == KeyEvent.VK_LEFT)
// gamePiece.left();
// // If "right arrow", then move the game piece to the right
// else if (event.getKeyCode() == KeyEvent.VK_RIGHT)
// gamePiece.right();
// // If the key code is 12 ("5 on the numeric keypad), rotate the game piece
// else if (event.getKeyCode() == 12)
// gamePiece.rotate();
// // If it's a space, then drop the game piece at top speed
// else if (event.getKeyCode() == KeyEvent.VK_SPACE)
// gamePiece.downMaximum();
// }
//
// step(); // Take a step
// field.print(); // Display the field
// Thread.sleep(300); // Pause for 300 milliseconds (about 1/3 of a second)
// }
field.setValue(2,6, 1);
// field.setValue(0,7, 1);
field.setValue(1,7, 1);
field.setValue(2,7, 1);
field.setValue(3,7, 1);
// field.setValue(4,7, 1);
// field.setValue(5,7, 1);
// field.setValue(6,7, 1);
field.setValue(0,8, 1);
field.setValue(1,8, 1);
field.setValue(2,8, 1);
field.setValue(3,8, 1);
field.setValue(4,8, 1);
field.setValue(5,8, 1);
field.setValue(6,8, 1);
field.setValue(0,9, 1);
// field.setValue(1,9, 1);
field.setValue(2,9, 1);
field.setValue(3,9, 1);
field.setValue(4,9, 1);
field.setValue(5,9, 1);
field.setValue(6,9, 1);
field.print();
field.removeFullLines();
field.print();
// Display "Game Over"
System.out.println("Game Over");
}
/**
* One step of the game
*/
public void step() {
// Drop the game piece lower
// If the game piece can't be placed in the current location:
// Put it back
// Land it
// If the game piece lands at the very top, then the game is over
// Remove the completed lines
// Create a new game piece
}
/**
* Setter for gamePiece
*/
public void setGamePiece(GamePiece gamePiece) {
this.gamePiece = gamePiece;
}
/**
* Setter for field
*/
public void setField(Field field) {
this.field = field;
}
public static Tetris game;
public static void main(String[] args) throws Exception {
// game = new Tetris(10, 20);
game = new Tetris(7, 10);
game.run();
}
}