private void TmrCountdown_Tick(object sender, EventArgs e)
        {                                            // On tick of the TmrCountdown
            TimerCount--;                            // Decrease one from the timer
            LblToStart.Text = TimerCount.ToString(); // Display the timer value on the panel

            if (TimerCount == 3)
            {                                // If the timer value is equal to 3
                LblGameStart.Visible = true; // Display the time till game start text
            }

            if (TimerCount == 0)
            {                                 // If the timer value is equal to 0
                LblToStart.Visible   = false; // Hide the second countdown
                LblGameStart.Visible = false; // Hide the time till game start text

                ButtonClicked = 1;            // Set the button as clicked

                // Enable the games timers
                TmrShark.Enabled       = true;
                TmrSurfer.Enabled      = true;
                BottleTimer.Enabled    = true;
                BottleTimeWait.Enabled = true;

                TmrCountdown.Stop(); // Stop the TmrCountdown

                TmrPopUp.Start();
                LblPopUp.Visible = true; // Display the popup text
                LblPopUp.Text    = "Game started";
            }
        }
Beispiel #2
0
        private void TmrCountdown_Tick(object sender, EventArgs e)
        {
            count--;                         //decrease count by 1
            LblTime.Text = count.ToString(); //display count in LblTime

            if (count == 0)
            {
                TmrCountdown.Stop();
                TmrAlien.Stop();
                LblScore.Enabled = false;
                LblTime.Enabled  = false;
                MessageBox.Show("Game Over!");
            }
        }
Beispiel #3
0
        private void PnlGame_MouseDown(object sender, MouseEventArgs e)
        {
            int    diffX  = e.X - alienRec.X;
            int    diffY  = e.Y - alienRec.Y;
            double length = Math.Sqrt(Math.Pow(diffX, 2) + Math.Pow(diffY, 2));

            if (length < 70)
            {
                score++;                          //add 1 to the score
                LblScore.Text = score.ToString(); // display the score
            }
            if (score == 10)
            {
                TmrAlien.Interval -= 70;
                label8.ForeColor   = System.Drawing.Color.Green;
            }
            if (score == 20)
            {
                TmrAlien.Interval -= 95;
                label5.ForeColor   = System.Drawing.Color.Green;
            }
            if (score == 30)
            {
                TmrAlien.Interval -= 150;
                label6.ForeColor   = System.Drawing.Color.Green;
            }
            if (score == 40)
            {
                TmrAlien.Interval -= 190;
                label7.ForeColor   = System.Drawing.Color.Green;
            }
            if (score == 50)
            {
                label9.ForeColor = System.Drawing.Color.Green;
                TmrCountdown.Stop();
                TmrAlien.Stop();
                LblScore.Enabled = false;
                LblTime.Enabled  = false;
                MessageBox.Show("Game Over! You win");
            }
        }