Architecture – The Interface
Picking up right where we stopped. We have made a ruff project of the game engine, now we'll do the same for the interface.
Our interface is pretty simple, and this is one of the reasons we chose a Tetris® clone. We shall have a class that represents a form, therefore a window, that will be our main window, where everything will happen in the game, and that's about it. Of course, we could (and we will) have a high score window, an about box, and stuff like that, but since that's not really a part of a Tetris® game, we will let that for the fine ajustments stage.
Ok, so lets talk about this main window. What should it need? Well, we don't have to think that hard, right? It needs a game board, where the blocks will fall and the pile will rest. It also needs a box to draw the next block, and places to inform the player of the current score, the number of completed lines and the current level. That's the basic. If I were you, I would consider putting a menu too, where you'll be able to start a game, pause a game, and quit the game. Later, that menu will have other things, like the help, and some options, like turning on and off sounds and music, choosing the direction of the blocks' rotation, and so on.
The game board and the box where the next block will be drawn will be picture boxes, because they have a graphics element where GDI+ can draw things. We can use labels to put the score, lines and level information. Now, for the really important part: we also need a timer where we will make the blocks go down, and where we will process each and every information the Game class gives us (that's the game loop). Oh, and that reminds me that we also need to instantiate the Game class in the interface.
Ok, so that's basically it. Not much for a project, right? Well, this is a simple interface, and later we will make a full scaled project of everything. Right now I'm worried about getting us to the real stuff: the coding phase. I know that developers usually get dying to start coding, so I'm trying to cut this short. :) Ok, so get your hands ready, open your Visual Studio or your SharpDevelop, and go do the basic drawing of your interface! WARNING: pleeeease, just DRAW IT. Don't do anything else, because the real start will be coding the engine, and that we will start in the next article.