We've made it to a break-point in our game's development. In this chapter we'll automate our game, so it will create new columns every second. And after that, we'll make our existing colums move to the right. We'll also check, if the conditions for Game Over, or New Level are met. The first step in this part is to add a timer to the form. You can find it in your ToolBox, under the 'Components' section. And when you double-click it, it won't be placed to the form. It will be placed in a new toolbar under your Form Designer window. Here's a screenshot:

So, click the timer in the components toolbar, and set it's properties like shown in the next table:
Timer
- (name): Game
- Interval: 1000
Obviously, the timer has a 'Interval' property. That tells the timer the 'lenght' of the pauses between repeating all of the commands writen in it's Tick method. The interval is defined in miliseconds. That means, if you want your timer to repeat it's code every second, you'll have to enter '1000' in it's interval property. And if you want it to repeat it's code every two and a half seconds – enter 2500. And so on, and so on, and … ;o)
So, now, we have the timer set – let's try it out. Double click on it in your components toolbar, and you'll see the code for it's Tick method. Add next lines of code in it's method:
// Call to our function responsible
// for creating new columns:
CreateNewColumn();
// Call our two 'draw' functions...
// So we can see when the new
// columns are created.
DrawField();
DrawGrid();
Ok, that'll do the trick. But, we have to tell our timer when to start 'ticking', and we'll do this with our 'New Game' button. So, go to the code for your button, and add this line of code after the existing lines:
// Telling our game timer to
// start ticking:
Game.Start();
Oh, and before moving on, remove, or comment out (check your C# toolbar for a button that does that) the code wich we used to test our field:
Field[0,0] = 1;
Field[4,8] = 2;
Field[2,12] = 3;
Field[9,14] = 4;
Don't worry, we don't need that code any more. Our blocks will be filled automaticaly, frow now on. Cool, heh? But wait untill you see this stuff in action! :o) Run your game, click on the button and enjoy the fireworks! Here's what you should see after 15 seconds (and after 15 column changes):

Moooooving on! As promised, we'll move all existing colums to the right. But that's the story from our next chapter.
One of the rules of our gameplay is the one saying that the game sends in new columns of blocks from the left. And it does so until the player runs out of empty columns… We'll divide this into three basic steps. And later on, we'll add a timer to our game. A timer will make sure that a new column will be created every time at a specified interval. These are the steps for our basic gameplay:
- Create new column with random colors
- Move existing columns to the right to make some room for the new column
- If we can't move any columns – Game Over!
- If the player cleared a certain ammount of columns – move him to a new level
And to make this work we'll declare some more variables – like the number of different colors allowed in the new column. By increasing this number, the game becomes more difficult to play. And one other way to make the game more difficult to play is by shortening the time interval between new column creation. The third way to make our game harder is to increase the number of columns needed to be cleared in a level. Later on, we'll incorporate all this stuff in our game. So, our game will become more and more difficult – from level to level.
Back to the code – here's what we need to add to our declarations:
// Declare the number of different colors
// that are used in the current level.
// We'll set it to 4 - for now:
int iColor = 4;
// Declare the counter that we'll use
// for changing colors every X levels.
int iColors;
// Declare the integer that will hold
// the number of columns created in
// the current level:
int iColumn;// Declare the integer that will hold
// the total number of columns in
// the current level.
int iColumns;
Add these lines of code right under the Game Field Height, Width, and Field Size declarations. Before moving on, we have to add a label to our form. So, add a label to the form, and then set it's properties like shown in the next list:
Label
- (name): lblColumn
- BackgroundColor: Web > Transparent
- Location: 555; 97
- Font: Microsoft Sans Serif; 9,75pt; style=Bold
- Text: 0/0
Finally, the code that will create our new column. Put it in your CreateNewColumn() function.
if (iColumn < iColumns)
{
// Initializing the random function.
// It will come up with random
// numbers every time we call it.
Random Rnd = new Random();
// We have to create 10 new fields.
// (Our column is 10 fields high.)
for (int p = 0; p < iHeight; p++)
{
// We set the random function in
// a way, so it couldn't return
// a value larger than we declared
// it in the beginning, and it
// couldn't return 0 (wich means –
// empty field).
Field[p, 0] = Rnd.Next(1, iColor + 1);
}
// Increase the number of columns created
iColumn++;
// Display the column count in the new
// label on our form.
lblColumn.Text = iColumn.ToString() +
"/" + iColumns.ToString();
}
else
{
// The level is over when the number
// of columns created in the current
// level is equal to the total number
// of columns predicted for that level.
// When the level is over, we call our
// methods for counting bonus points
// and switching to a new level.
LevelScore();
NewLevel();
}
That's it for this chapter. In the next one, we'll add a timer to our game, and add some code to make it create new colums every second. We'll also start talking about moving all existing colums to the right.