// The Timer Function to increase the value of timestamp every one second private void timer_Tick(object sender, EventArgs e) { if (gamePaused == false) { //TODO : Apply a mechanism to prevent the overflow of a timestamp timeStamp += 1; //Generate the xy co-ordinated for the BOMB if (timeStamp % BombDisplayTime == 0) { BombFrame = new Image <Gray, byte>(640, 480, new Gray(1)); XYCoordinatesOfBomb[0, 0] = CommonUtil.generateRandomXCoordinate(640); XYCoordinatesOfBomb[0, 1] = CommonUtil.generateRandomYCoordinate(480); } // increase number of balls to be displayed #region Increase the Number Of Balls LabelGameMessage.Hide(); if ((timeStamp % TimeIntervelToIncreaseBalls) == 0) { LevelNumber++; LabelGameMessage.Text = "↑ Level UP ↑ \n Level " + LevelNumber; LabelGameMessage.Show(); IncreaseNumberOfBallsDrawn(); } #endregion } }
// The Onload Event Handler. // Here it adds an event handler that executes the Process Frame Object every time the application is idle private void Form1_Load(object sender, EventArgs e) { BackgroundMusic.URL = Constants.BACKGROUND_MUSIC_FILE_LOC; //a.controls.play(); LabelGameMessage.Hide(); SplashScreen s = new SplashScreen(); this.Hide(); gamePaused = true; s.ShowDialog(); this.Show(); gamePaused = false; // initilise the images for (int i = 0; i < 10; i++) { Balls[i] = new Image <Gray, byte>(640, 480, new Gray(1)); generateXYCoordiantesForBall(i); } ibOriginal.Width = this.ClientRectangle.Width; ibOriginal.Height = this.ClientRectangle.Height - 24; Application.Idle += ProcessFrame; }