Jump to content
  • Advertisement
Sign in to follow this  
Grantyt3

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!