Question: Could someone please fix my isItOutOfBounds method so that it shows a game over message and exits the program. Currently it seems not to work
Could someone please fix my isItOutOfBounds method so that it shows a "game over" message and exits the program. Currently it seems not to work im calling it in my validateMove method.
public class TetrisGame
private TetrisBrick fallingBrick;
private int rows ;
private int cols ;
private int numBrickTypes ;
private Random randomGen;
private int background;
private int state;
private int score;
public TetrisGameint rows, int cols
this.rows rows;
this.cols cols;
initBoard;
this.randomGen new Random;
spawnBrick;
public void makeMovechar moveCode
if moveCode D
fallingBrick.moveDown;
ifvalidateMovefalse
fallingBrick.moveUp;
whiletrue
ifisBlockOutOfBounds
JOptionPane.showMessageDialognull"Game Over";
break;
transferColor;
copyAllRows;
spawnBrick;
else ifmoveCode L
fallingBrick.moveLeft;
ifvalidateMovefalse
fallingBrick.moveRight;
else ifmoveCode R
fallingBrick.moveRight;
ifvalidateMovefalse
fallingBrick.moveLeft;
else ifmoveCode U
fallingBrick.rotate;
ifvalidateMove false
fallingBrick.unrotate;
else ifmoveCodeN
newGame;
else ifmoveCodeS
saveToFile;
private boolean isBlockOutOfBounds
int blockHeight rows;
iffallingBrickposition
return true;
return false;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
