You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
886 B
Markdown
46 lines
886 B
Markdown
# 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??
|