Broderick-Westrope / tetrigo

Play Tetris in your terminal.
GNU General Public License v3.0
273 stars 15 forks source link

Panic: Attempts to move tetrimino down when there is a blocking cell. #1

Closed Broderick-Westrope closed 11 months ago

Broderick-Westrope commented 11 months ago

When the current tetrimino is being lowered (via any method) such that a cell above the lowest row cannot move down, but the lowest row can move down, a panic will be thrown stating the higher (blocked) cell could not be moved down. An example of this situation can be seen in the following diagram, where the orange "J" tetrimino will cause a panic once it attempts to lower beyond the blue "I" tetrimino.

CleanShot 2023-11-27 at 16 42 10

I believe this is caused by Tetrimino.CanMoveDown which is currently checking for collisions on the bottom row only. A better approach would be to check collisions for the bottom cell of each column.

Broderick-Westrope commented 11 months ago

A similar thing happens when moving left (or right), and the blocked cell is not the most left (or right) cell.

Broderick-Westrope commented 11 months ago

see commit