TetrisNET
This was one of my first projects with C#. At the time C# was still in Beta 2. I used the tetris idea as a way to learn more about the framework and how the language works.
My first hack is based around 3 objects: CTetrisGame, CTetrisBoard, and CShapeBase.
CTetrisGame controls the game and does the rendering. It also handles game play such as checking for completed lines and game scores. It's a rough sketch of the controller in MVC.
CTetrisBoard simply manages the game board. It remembers where blocks are stored and does boundary checking. CTetrisGame encapsulates an instance of this object.
CShapeBase starts an object hierarchy to represent each shape. CShapeBase encapsulates the basic shape functionality such as movement and rotation. Each concrete shape inherits from the CShapeBase and overrides the layout of itself. CTetrisGame then randomly picks the shape from an array of shape instances to handles the game action.
Future ideas included a remote service to record game scores. That idea was never fully implemented. Another idea was to add sound. I left the hooks in place but they are commented out in the current source.
If I were to redesign the source code I would have implemented a more traditional MVC architecture. Linked here is the "solution" updated with Visual C# 2005 Express Edition. Feel free to download and critique. I love feed back.
[Download Source and Executable]

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home