####TET.RS Tetris is a deceptively challenging game to program - especially if, like me, you’ve only really made action games before. I got pretty frustrated trying to wrap my head around the architecture of the program - this conceptual implementation was a great help.
Creating a system that restricts the movement and rotation of the pieces to make sure they don’t leave the boundaries of the grid or clip placed blocks is tough. In the end I went with an ‘undo’ system that makes the tranformation (rotational or horizontal), checks whether that new position is valid, and undoes the transformation if it’s not. Moving blocks are not monitored by the grid manager, only when they reach a resting position are the cells ‘checked in’ to the grid. At this point we check & clear full rows and shift down the above rows appropriately.