Tetris Clone

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Tetris Clone

      I am planning to make a Tetris clone as I am just starting out. It will be a windows-only program as I am trying to get the hang of Windows/DirectX programming (the book needs an API tutorial because it leaves beginning game-programmers like me in the dark).

      Anyways, I am trying to think about how will I structure this game, and I thought I should collaborate with others while making and planning the game to make sure I don't develop any bad habits.

      All I have so far are rudimentary thoughts on how I will store the objects- a 2d array for the grid and each tetris piece will be a array of blocks.

      What else do I have to think about when making this and any (constructive)suggestions about making the game are welcome.
    • I just did this a few months ago Using the GCC4 engine.

      [IMG:http://www.jason-wendlandt.com/wp-content/uploads/2012/05/gameplay-01.jpg]

      I went the same route. I used a 10x20 2D array to store locations of block pieces. (Actually it became a 10x25 array to handle elements that were just created but still off screen.) I essentially stored my Actor ID information in the Grid array, and then I would perform my game logic against the grid and would move/destroy blocks using that information.

      I think the biggest road block I ran into was how to destroy the pieces of the blocks. I started out with static blocks that I had modeled in Blender and exported out to sdkmesh, which worked great , appearance wise, until I wanted to destroy a section of the mesh. I ended up piecing together tetris blocks with individual cubes to solve this. Then I could just destroy pieces of a block by removing specific cubes from it's SceneNode hierarchy.

      Other than that, i pretty much based my logic off of the Tetris Wikipedia page here: en.wikipedia.org/wiki/Tetris

      I hope that helps a bit. :)
    • Thanks,

      As you might have interpreted, I am going to make and use my own engine.

      Is there any technical reason to create pieces off-screen? I would rather just make the small grid and put pieces directly on-screen. I already decided to keep my pieces as individual block objects for simplicity. I guess I need not worry about that.

      However, after talking about pieces, I do have a specific question in mind. How do you randomize pieces and how do you center it? Can you go about "predefining" different pieces using inheritance or something?
    • I made the pieces appear off screen so that they would slide into the game board rather than just appear out of nowhere. So it was really just an aesthetic thing.

      My tetris pieces where pre-defined as XML actor types. So I had my L-Block.xml, J-Block.xml, etc. Then in code I store my block xml file names in a vector, get a random number between 0 and n-1, where n was my number of block types, and load that xml file name at the given index.