# Tetris Block Rotation

This topic is 4593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm making a Tetris remake, and you know how in Tetris games, you can usuallly press a button and it will rotate the falling shape? How is that usually handled? Anyone know?

##### Share on other sites
You use Linear transformations. It takes a little linear algebra to understand, but Aaron Cox's tetris tutorial explains it really well. Scroll down to the bottom of this page to where he talks about rotation. He explains it better than I can [smile].

Hope that helps.

##### Share on other sites
Just use four stones, each representing one possible rotation. So instead of 7 stones you'll end up with 28, but that way you don't have to rotate them manually and save yourself a lot of headaches.

##### Share on other sites
Yeah, if it's 3D and you want to make the rotation all fancy looking, then you can use a rotation transformation. Otherwise, just use presets to switch between orientations (like in original Tetris). Either way though, you'll want to have internal representations of all the pieces in all their orientations so you can use them for when you're doing collision with the pieces at the bottom of the screen and such.

-Auron

##### Share on other sites
You can also use a 4x4 grid with your shape being masked out in that 4x4 grid and rotate the data in the cells.

Make a temporary 4x4 grid and copy the rotated cells in the original 4x4 grid to the temporary grid and return the temporary grid.

This works fine except for the bar does not rotate as well as the other pieces. since 2 clock-wise rotations places the bar one coloumn over from where it was.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633301
• Total Posts
3011268
• ### Who's Online (See full list)

There are no registered users currently online

×