Tetris Rotation Problem

Started by
13 comments, last by Mekuri 11 years, 6 months ago

I recovered my password and spent lots of time trying to retrieve my old account here just to say that that video tutorial of yours is really well done and helpful! GJ!


Heh, thanks. smile.png

+---------------------------------------------------------------------+

| Game Dev video tutorials -> http://www.youtube.com/goranmilovano | +---------------------------------------------------------------------+
Advertisement

I made a quick video tutorial that explains how to rotate a tetris block with matrices. I hope you find it hepful:

[media]
[/media]

Sorry for getting to this late. But that was very informative. That's exactly what I needed. I'll get back to you guys on my progress.

@pointer: Your solution works, too. It's mostly helps without having to do an exception case of if the block is a 2 x 2 square, then there won't be a rotation at all. Visual, anyway.

I preferred a source that described the game itself. Search for section 5.3 on this page: Link It helped me a lot.

Indeed. Rotating Tetris pieces doesn't need "general" algorithms, only a table of how each actual piece rotates. It is the heart of the game, and it has to be perfect: for example, if rotating an O piece, an horizontal I piece twice, or a S,Z,L,J,T piece four times in the same direction shifts it left or right we are playing a major variant, not standard Tetris.

Transform matrices might be a good idea (depending on the game engine architecture in use), but they are only useful to implement the desired piece moves, not to design them.

Omae Wa Mou Shindeiru


Indeed. Rotating Tetris pieces doesn't need "general" algorithms, only a table of how each actual piece rotates. It is the heart of the game, and it has to be perfect: for example, if rotating an O piece, an horizontal I piece twice, or a S,Z,L,J,T piece four times in the same direction shifts it left or right we are playing a major variant, not standard Tetris.

Transform matrices might be a good idea (depending on the game engine architecture in use), but they are only useful to implement the desired piece moves, not to design them.

Part of my reason for using it was to lay out all the rules and moves and allow me to come up with how I wanted to implement them. The state space is small enough you could just save each rotation and move between them, using checks to see if the new move would be possible or not.
I recently challenged myself to make a tetris game in one day, using XNA. I too spend a lot of time trying to figure out how to rotate the pieces, but I came to the conclusion that it was overkill for such a simple game. I went with hardcoding each possible rotation for the pieces, which isn't that much (Four rotations for L, J and T, Two for S, Z and I, and none for the O).

If you want to calculate rotations because you want to learn how to, it's a good idea- If not, I would consider it overkill. dry.png

Check out the game I am making here - http://www.youtube.com/user/NasarethMekuri

This topic is closed to new replies.

Advertisement