# Design

## Tetris

Matrix Multiplication for rotating pieces.

Each piece (shape) contains a Mat4 containing a representation of it's shape.
For example:

```
0 1 0 0
0 1 0 0
0 1 0 0
0 1 0 0
```

This is the classic `line` piece.

And here it is on it's `up` side

```
0 0 0 0
1 1 1 1
0 0 0 0
0 0 0 0
```

And here is the `t` piece

```
0 1 0
1 1 1
0 0 0
```

A matrix multiplication is applied to this Mat6 to achieve a piece rotation.

When that matrix is updated, the 4 blocks parented to the shape are moved to reflect this new shape.

This matrix also allows us to do checks to see if any of the blocks in the shape would intersect with another piece on the board.
We can also check if a piece would go out of bounds during a move or rotation.

We can use this to "plan -> validate -> commit" changes based on user input.

Question: How the fuck do matrix multiplications work??
