Tetris Block Rotation

Started by
3 comments, last by GameDev.net 18 years ago
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?
Advertisement
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.
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.
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
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.

This topic is closed to new replies.

Advertisement