Jump to content
  • Advertisement
Sign in to follow this  
NecoSpes

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.

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

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


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

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!