# Tetris

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

## Recommended Posts

How would -you- make the blocks rotate? So far I have the blocks as individual classes and figure, a class of blocks. Would you just make a matrix and somehow rotate the blocks? Or make an array of the different states? Just asking for a general idea~ Thanks in advance.

##### Share on other sites
I've done tetris once myself. My method was to use the array of states. This had the advantage of allowing me to manually take care of the issue of ambiguous centers of rotation. That problem always bugged me, though I suppose there really isn't an optimal solution unless you turn the tetris world into a continuous one, rather than discrete.

The technical details were that I had a constant 4-dimensional array of bools: bool Shapes[7][4][4][4]. Seven shapes, four rotations each, represented by a 4-by-4 array of bools that were true for any square where there was a block and false for any square that was empty. Then, I represented a falling block by storing the shape index, rotation index, and (x, y) offset. Once a block had fallen, I just wrote individual squares to the overall playing field. No reason to remember that all four squares belong to the same block anymore, if you stick to the traditional gameplay. (You might record a value for each square, so that you can draw it differently, but functionally it works the same as any other square.)

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633735
• Total Posts
3013596
×