Erm tetris question

Started by
10 comments, last by NullPointer33 20 years, 6 months ago
If you go element by element, it's pretty easy to figure out how to make a rotated version of an array, especially if you write out what you need to do on paper.

If I were writing Tetris right now, I would have a current block object, that had randomly been assigned a block configuration from the 7? "base type" blocks. To rotate, call CurrentBlock.rotate(DIRECTION). No real need to hardcode all the block type ROTATIONS. Makes it easier if you want to put some spin on your game and make new block shapes too.

I don't know how relevant this is, but whatever

[edited by - Peon on October 22, 2003 5:07:16 PM]
Peon
Advertisement
quote:
If you go element by element, it''s pretty easy to figure out how to make a rotated version of an array, especially if you write out what you need to do on paper.

If I were writing Tetris right now, I would have a current block object, that had randomly been assigned a block configuration from the 7? "base type" blocks. To rotate, call CurrentBlock.rotate(DIRECTION). No real need to hardcode all the block type ROTATIONS. Makes it easier if you want to put some spin on your game and make new block shapes too.

I don''t know how relevant this is, but whatever


I did this approach on the first version I did. Of course, every time I wanted to do a rotation, I had to switch from my board coordinates, to the block coordinates, do the rotation, and then switch back to the board coordinates. I thought it was a whole lot cleaner to just do it all with the one big array, with indexes moving about.

This topic is closed to new replies.

Advertisement