Rotation

In this lesson, we will explore how we can use math to rotate tetrominoes.

Now we can move around, but to make it more fun, let’s make the piece rotate. This is what the different stages of rotation should look like:

Rotation of tetromino
Rotation of tetromino

As with most components of this game, there are a few ways we could go about solving this challenge. We could, for example, have all the different variations of matrices defined and loop through them. However, this would require a lot of boilerplate code, so let’s not take that route this time.

Linear algebra

Instead, there is a mathematical formula in the linear algebra branch of mathematics that we can use. The ...

Get hands-on with 1400+ tech skills courses.