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!"); } }
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"); } }
private void MnuStart_Click(object sender, EventArgs e) { score = 0; TmrAlien.Start(); //start the timer TmrCountdown.Start(); }