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.
0 comments:
Post a Comment