void TryMove(MovableGrid test) { if (!(OutsideBoard(test) || HitAnotherBlock(test))) { fallingBlock = test; } }
public void Drop(Tetromino shape) { checkIfAlreadyFalling(); int row = StartingRowOffset(shape); fallingBlock = new MovableGrid(shape).MoveTo(row, Cols / 2 - shape.Columns() / 2); }
private void TryMove(MovableGrid mg) { if (!ConflictwithBoard(mg)) { this.fallingBlock = mg; } }
public void Drop(Tetromino shape) { CheckIsFalling(); int r = StartingRowOffset(shape); fallingBlock = new MovableGrid(shape).MoveTo(r, Columns / 2 - shape.Columns() / 2); }
public void Tick() { for (int col = 0; col < columns; col++) { if (board[rows - 1, col].getLetter() != '.') { board[rows - 1, col].isFalling = false; } } for (int row = rows - 2; row >= 0; row--) { for (int col = 0; col < columns; col++) { if (board[row, col].getLetter() != '.' && board[row + 1, col].getLetter() == '.') { MovableGrid tmp = board[row, col]; board[row, col] = board[row + 1, col]; board[row + 1, col] = tmp; board[row, col].isFalling = true; } else { board[row, col].isFalling = false; } } } }
private void TryMove(MovableGrid test) { if (!ConflictWithBoard(test)) { fallingBlock = test; } }
public void Drop(Grid shape) { CheckIfFalling(); movingGrid = new MovableGrid((Tetromino)shape); movingGrid = movingGrid.MoveTo((columns / 2 - shape.Columns() / 2), StartingRowOffset(shape)); fallingBlock = true; refreshTab(null, movingGrid); }
public void Drop(Tetromino tetromino) { CheckIfFalling(); int row = StartingRowOffset(tetromino); MovableGrid mg = new MovableGrid(tetromino); this.fallingBlock = mg.MoveTo(row, (this.columns / 2) - (tetromino.Columns() / 2)); }
private void init() { board = new MovableGrid[rows, columns]; for (int row = 0; row < rows; row++) { for (int col = 0; col < columns; col++) { board[row, col] = new MovableGrid('.'); } } }
public void Tick() { MovableGrid test = fallingBlock.MoveDown(); if (ConflictWithBoard(test)) { StopFallingBlock(); } else { fallingBlock = test; } }
void CoptyToBoard(MovableGrid block) { for (int row = 0; row < Rows; row++) { for (int col = 0; col < Cols; col++) { if (block.isAt(row, col)) { board[row, col] = block.CellAt(row, col); } } } }
void CopyToBoard(MovableGrid block) { for (int row = 0; row < this.rows; row++) { for (int col = 0; col < this.columns; col++) { if (block.IsAt(row, col)) { this.board[row, col] = block.CellAt(row, col); } } } }
void CopyToBoard(MovableGrid block) { for (int r = 0; r < Rows(); r++) { for (int c = 0; c < Columns(); c++) { if (block.IsAt(r, c)) { board[r, c] = block.CellAt(r, c); } } } }
public void Drop(Grid Shape) { MovableGrid newBlock = new MovableGrid(Shape); int center = columns / 2; if (board[0, center].getLetter() != '.') { throw new System.ArgumentException("A block is already falling."); } else { board[0, center] = newBlock; } }
public void MoveRight() { MovableGrid test = movingGrid.MoveRight(); refreshTab(movingGrid, null); if (!ConflictsWithBoard(test)) { refreshTab(null, test); movingGrid = test; } else { refreshTab(null, movingGrid); } }
public void MoveDown() { MovableGrid test = movingGrid.MoveDown(); refreshTab(movingGrid, null); if (!ConflictsWithBoard(test)) { refreshTab(null, test); movingGrid = test; } else { StopFallingBlock(); refreshTab(null, movingGrid); } }
void TryRotate(MovableGrid rotated) { MovableGrid[] moves = { rotated, rotated.MoveLeft(), rotated.MoveRight(), rotated.MoveLeft().MoveLeft(), rotated.MoveRight().MoveRight(), }; foreach (MovableGrid test in moves) { if (!(OutsideBoard(test) || HitAnotherBlock(test))) { fallingBlock = test; return; } } }
public void refreshTab(MovableGrid oldPiece, MovableGrid newPiece) { if (oldPiece != null) { for (int i = 0; i < oldPiece.Rows(); i++) { for (int j = 0; j < oldPiece.Columns(); j++) { if (oldPiece.Y + i >= 0 && oldPiece.CellAt(i, j) != '.') { blocks[oldPiece.Y + i, oldPiece.X + j] = '.'; } } } } if (newPiece != null) { for (int i = 0; i < newPiece.Rows(); i++) { for (int j = 0; j < newPiece.Columns(); j++) { if (newPiece.Y + i >= 0 && newPiece.CellAt(i, j) != '.') { blocks[newPiece.Y + i, newPiece.X + j] = newPiece.CellAt(i, j); } } } } if (!IsFallingBlock()) { for (int row = 0; row < rows; row++) { int contain = 0; for (int col = 0; col < columns; col++) { if (blocks[row, col] != '.') { contain++; } } if (contain == columns) { DeleteRow(row); } } } }
public void MoveDown() { if (!IsFallingBlock()) { return; } MovableGrid mg = this.fallingBlock.MoveDown(); if (ConflictwithBoard(mg)) { StopFallingBlock(); RemoveFullRows(); } else { this.fallingBlock = mg; } }
public void MoveDown() { if (!IsFallingBlock()) { return; } MovableGrid test = fallingBlock.MoveDown(); if (OutsideBoard(test) || HitAnotherBlock(test)) { StopFallingBlock(); checkFullRows(); } else { fallingBlock = test; } }
private void TryRotate(MovableGrid test) { MovableGrid[] moves = { test, test.MoveLeft(), test.MoveRight(), test.MoveLeft().MoveLeft(), test.MoveRight().MoveRight() }; foreach (MovableGrid move in moves) { if (!ConflictWithBoard(move)) { fallingBlock = move; return; } } }
private void TryRotate(MovableGrid rotated) { MovableGrid[] moves = { rotated, rotated.MoveLeft(), // wallkick moves rotated.MoveRight(), rotated.MoveLeft().MoveLeft(), rotated.MoveRight().MoveRight(), }; refreshTab(movingGrid, null); foreach (MovableGrid test in moves) { if (!ConflictsWithBoard(test)) { refreshTab(null, test); movingGrid = test; return; } } refreshTab(null, movingGrid); }
void StopFallingBlock() { CopyToBoard(fallingBlock); fallingBlock = null; }
bool ConflictwithBoard(MovableGrid rotated) { return(rotated.OutsideBoard(this) || rotated.HitsAnotherBlock(this)); }
void StopFallingBlock() { CopyToBoard(this.fallingBlock); this.fallingBlock = null; }