Search code examples
c#xnatetris

How do I create Tetris Blocks in XNA with C#?


I'm making a Tetris Clone in C# with XNA, and I'm unsure of how to actually implement the blocks.

I don't think that making the shapes as images will work (because parts are removed when lines are formed), so I Have blocks to make up the pieces like This.

Unfortunately, I don't know how to actually define the blocks to make the pieces, nor do I know how to manipulate them to make them rotate, etc.

Edit: I would also need assistance in learning how to make the Tetris Grid too.


Solution

  • I haven't created tetris before, but after some thinking, I believe that I would use a simple matrix to create my pieces. For example, your whole game board would be one big matrix. A subset of that matrix, say a 4x4 block of it, would be a game piece. Which parts of that 4x4 block would be filled would be determined by which particular piece you want to create. Each part of the matrix can have a boolean flag that would indicate if it's filled or not. This is a very simplistic view of it, but I think it's a viable solution.