コード例 #1
0
 private void Play_Click(object sender, EventArgs e)
 {
     if (demClickPlay % 2 != 0)
     {
         Timer_Chay.Start();
         TimerChim.Start();
         TimerChim.Interval = 100;
     }
     else
     {
         Timer_Chay.Stop();
         TimerChim.Stop();
     }
     demClickPlay++;
 }
コード例 #2
0
 private void TimerChim_Tick(object sender, EventArgs e)
 {
     //this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
     if (y_ConChim + ConChim.Height <= this.Height)
     {
         y_ConChim += 15;
         this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
         bool Check_Play = false;
         if (x_ConChim + ConChim.Width >= x_cap1 && x_ConChim + ConChim.Width <= x_cap1 + OngCongTren1.Width)
         {
             if (y_ConChim <= 709 + y_ongtren1 || y_ConChim + ConChim.Height >= y_ongduoi1)
             {
                 Timer_Chay.Stop();
                 //TimerChim.Stop();
                 if (TimerChim.Interval == 100)
                 {
                     Check_Play = true;
                     SoundPlayer sound = new SoundPlayer("Dead.wav");
                     sound.LoadAsync();
                     sound.Play();
                 }
                 TimerChim.Interval = 300;
             }
         }
         ConChim.Location = new Point(x_ConChim, y_ConChim);
         if (x_ConChim + ConChim.Width >= x_cap2 && x_ConChim + ConChim.Width <= x_cap2 + OngCongTren1.Width)
         {
             if (y_ConChim <= 709 + y_ongtren2 || y_ConChim + ConChim.Height >= y_ongduoi2)
             {
                 Timer_Chay.Stop();
                 if (TimerChim.Interval == 100)
                 {
                     Check_Play = true;
                     SoundPlayer sound = new SoundPlayer("Dead.wav");
                     sound.LoadAsync();
                     sound.Play();
                 }
                 TimerChim.Interval = 300;
             }
         }
         ConChim.Location = new Point(x_ConChim, y_ConChim);
         if (x_ConChim + ConChim.Width >= x_cap3 && x_ConChim + ConChim.Width <= x_cap3 + OngCongTren1.Width)
         {
             if (y_ConChim <= 709 + y_ongtren3 || y_ConChim + ConChim.Height >= y_ongduoi3)
             {
                 Timer_Chay.Stop();
                 if (TimerChim.Interval == 100)
                 {
                     Check_Play = true;
                     SoundPlayer sound = new SoundPlayer("Dead.wav");
                     sound.LoadAsync();
                     sound.Play();
                 }
                 TimerChim.Interval = 300;
             }
         }
         if (Check_Play == true)
         {
             if (MessageBox.Show("Điểm: " + DiemSo.ToString() + "\n Ê có chơi tiếp không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 Timer_Chay.Stop();
                 TimerChim.Stop();
                 Refesh();
                 DiemSo = 0;
             }
             else
             {
                 Application.Exit();
             }
         }
         ConChim.Location = new Point(x_ConChim, y_ConChim);
     }
 }