Introduction
Playing games not set up correctly can be really annoying and frustrating.
I’m not a huge gamer, but every now and then I’d like to see if I can beat my
score on Spider Solitaire. Getting into the game market now, because of my
daughter, I have come to realise how many games there are out there, which were
created quickly and haphazardly. Call me stupid, but I believe the most
most important part of game design ( doesn’t matter what game it is ), is the
displaying and smoothness of of all objects. It looks very unprofessional
when, upon a certain movement the game flickers or the moved object simply
doesn’t move quick enough. It is especially bad when the moved object(s)
still leave traces of their original location after the move. All these
reasons spurred me on, to ensure that I create a proper display class, so that
issues like the aforementioned issues never ever arise.
Logic / Explanation
You may be thinking: "How can these issues be fixed, if possible even?" Two
words :
Double Buffering. What we will do in this article is create a class that can
handle all the image buffering. Once we have this class created, we create
objects from it for our Preview window, our Splash window as well as our
physical game window. In
Part 1 of this series we have created the Grid for all the Tetris blocks,
and designed the basic user interface. Now, we will take it a tiny step
further, by adding more controls and setting default values for all the labels
as well as beginning with the actual game’s logic. Let us start with the
design
Design
If you haven’t completed the
first part’s exercise, I suggest you do so now. If you have completed it you
will know that the main interface was just a black panel. We will expand on
that now. Open part 1, and add the following controls with their
associated Properties :
Control | Property | Setting |
---|---|---|
Label | Text | Score |
Label | Text | Level |
label | Text | Rows |
Label | Name | lblTetScore |
Text | Empty | |
BorderStyle | Fixed3D | |
Label | Name | lblTetLevel |
Text | Empty | |
BorderStyle | Fixed3D | |
Label | Name | lblTetRows |
Text | Empty | |
BorderStyle | Fixed3D | |
Label | Text | Preview |
Panel | Name | pnlTetPreview |
BackColor | Black | |
Size | 115, 67 | |
Panel | Name | pnlMovement |
Timer | Name | tmrTet |
Resize your main form where necessary. Not all of the controls added now are
100% essential at this stage, but it is good to have the User Interface up to
this point, so that you can also get a larger picture of what will happen in
this game, and what is to be expected.
Your design should more or less resemble the following picture
Figure 1.1