private void MoleShooter_MouseClick(object sender, MouseEventArgs e) { if (e.X > 1230 && e.X < 1290 && e.Y > 220 && e.Y < 235) //Start { timerGameLoop.Start(); } else if (e.X > 1230 && e.X < 1290 && e.Y > 248 && e.Y < 265) //Stop { timerGameLoop.Stop(); } else if (e.X > 1230 && e.X < 1290 && e.Y > 270 & e.Y < 287) //Reset { timerGameLoop.Stop(); } else if (e.X > 1230 && e.X < 1290 && e.Y > 294 && e.Y < 313) //Quit { timerGameLoop.Stop(); } else { if (_mole.Hit(e.X, e.Y)) { splat = true; _splat.Left = _mole.Left - Resources.Splat.Width / 3; _splat.Top = _mole.Top - Resources.Splat.Height / 3; } } Firegun(); }
//MoleShooter_MouseClick method give condition to distince the control board items //and include Hit() and Misses() method //when user click - it means that user try to shot the mole //if user shot correct , Hit() method is called //if user shot incorrect, Misses() method is called private void MoleShooter_MouseClick(object sender, MouseEventArgs e) { if (e.X > 660 && e.X < 704 && e.Y > 242 && e.Y < 256) { timerGameLoop.Start(); } else if (e.X > 661 && e.X < 696 && e.Y > 259 && e.Y < 271) { timerGameLoop.Stop(); } else if (e.X > 661 && e.X < 703 && e.Y > 277 && e.Y < 289) { splat = false; timerGameLoop.Stop(); _hits = 0; _misses = 0; _totalShots = 0; _averageHits = 0; _mole.Left = 300; _mole.Top = 450; } else if (e.X > 660 && e.X < 694 && e.Y > 295 && e.Y < 306) { timerGameLoop.Stop(); DialogResult result = MessageBox.Show(this, " Do you really want to exit?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { this.Close(); } } else { //Hit condition which is called from Hit() method in CMole class //(e.X, e.Y) here is the center point position, not mole position if (_mole.Hit(e.X, e.Y)) { splat = true; _splat.Left = _mole.Left - Resources.Splat.Width / 3; _splat.Top = _mole.Top - Resources.Splat.Height / 3; _hits++; } else { _misses++; } _totalShots = _hits + _misses; _averageHits = (double)_hits / (double)_totalShots * 100.0; } // Call FireGun() method to create Gun sound FireGun(); }
private void MoleShooter_MouseClick(object sender, MouseEventArgs e) { if (e.X > 426 && e.X < 466 && e.Y > 97 && e.Y < 106) // Start hot spot { timerGameLoop.Start(); } else if (e.X > 426 && e.X < 460 && e.Y > 115 && e.Y < 125) // Stop hot spot { timerGameLoop.Stop(); } else if (e.X > 426 && e.X < 466 && e.Y > 132 && e.Y < 142) // Reset hot spot { timerGameLoop.Stop(); } else if (e.X > 426 && e.X < 458 && e.Y > 151 && e.Y < 161) // Quit hot spot { timerGameLoop.Stop(); } else { if (_mole.Hit(e.X, e.Y)) { splat = true; _splat.Left = _mole.Left - Resources.splatter.Width / 3; _splat.Top = _mole.Top - Resources.splatter.Height / 3; _hits++; } else { _misses++; } _totalShots = _hits + _misses; _averageHits = (double)_hits / (double)_totalShots * 100; } FireGun(); }
private void MoleShooter_MouseClick(object sender, MouseEventArgs e) { if (e.X > 620 && e.X < 723 && e.Y > 38 && e.Y < 57) { timerGameLoop.Start(); } else if (e.X > 620 && e.X < 698 && e.Y > 69 && e.Y < 90) { timerGameLoop.Stop(); } else if (e.X > 620 && e.X < 723 && e.Y > 102 && e.Y < 120) { timerGameLoop.Stop(); _totalScrore = 0; _hits = 0; _missed = 0; _averageHits = 0; } else if (e.X > 620 && e.X < 694 && e.Y > 134 && e.Y < 155) { timerGameLoop.Stop(); Application.Exit(); } else { if (_mole.Hit(e.X, e.Y)) { splat = true; _splat.Left = _mole.Left - Resources.splat.Width / 3; _splat.Top = _mole.Top - Resources.splat.Height / 3; _hits++; } else { _missed++; } _totalScrore = _missed + _hits; _averageHits = Math.Round((double)_hits / (double)_totalScrore * 100.0); } fireSound(); }
private void MoleShooter_MouseClick(object sender, MouseEventArgs e) { if (e.X > 1044 && e.X < 1161 && e.Y > 387 && e.Y < 421) // Start hot Spot { timerGameLoop.Start(); } else if (e.X > 1052 && e.X < 1150 && e.Y > 436 && e.Y < 467) // Stop hot Spot { timerGameLoop.Stop(); } else if (e.X > 1042 && e.X < 1156 && e.Y > 482 && e.Y < 512) // Reset hot Spot { timerGameLoop.Stop(); } else if (e.X > 1052 && e.X < 1150 && e.Y > 529 && e.Y < 563) // Quit hot Spot { timerGameLoop.Stop(); } else { if (_mole.Hit(e.X, e.Y)) { splat = true; _splat.Left = _mole.Left - Resources.Splat.Width / 3; _splat.Top = _mole.Top - Resources.Splat.Height / 3; _hits++; } else { _misses++; } _totalShots = _hits + _misses; _averageHits = (double)_hits / (double)_totalShots * 100.0; } FireGun(); }