Exemplo n.º 1
0
 private void play_Click(object sender, EventArgs e)
 {
     if (dem >= 0)
     {
         TimerVuNo.Interval = 300;
     }
     if (dem % 2 != 0)
     {
         timerDiChuyenXe.Start();
         TimerXe2.Start();
         TimerBGR.Start();
     }
     if (dem == 1)
     {
         xeComputer1.Visible = true;
         xeComputer2.Visible = true;
     }
     if (dem % 2 == 0)
     {
         timerDiChuyenXe.Stop();
         TimerXe2.Stop();
         TimerBGR.Stop();
     }
     dem++;
 }
Exemplo n.º 2
0
 private void btnstart_Click(object sender, EventArgs e)
 {
     start.Visible    = false;
     btnstart.Visible = false;
     btnstart.Enabled = false;
     timerDiChuyenXe.Start();
     TimerXe2.Start();
     TimerBGR.Start();
 }
Exemplo n.º 3
0
        public void SetCarPlay(PictureBox name, int x, int y)
        {
            name.Visible = true;
            if (name.Visible == true)
            {
                y_computer[y] += 5;
            }

            // X [0:493]
            name.Location = new Point(x_computer[x], y_computer[y]);

            if (y_computer[y] >= this.Height)
            {
                diem++;
                lblDiemSo.Text = diem.ToString();

                if (diem > 20)
                {
                    xeComputer3.Visible = true;
                    TimerXe3.Start();
                }
                if (diem > 40)
                {
                    xeComputer4.Visible = true;
                    TimerXe4.Start();
                    TimerXe2.Interval = 1;
                }
                if (diem > 60)
                {
                    timerDiChuyenXe.Interval = 1;
                    TimerXe2.Interval        = 1;
                    TimerXe3.Interval        = 1;
                    TimerXe4.Interval        = 1;
                }
                y_computer[y] = 0; // set lại
                Random rd = new Random();
                x_computer[x] = rd.Next(95, this.Width - 95 - name.Width);
            }
            // Kiểm tra va chạm giữa 2 pic
            // if (xeComputer1.Location.Y +xeComputer1.Height == xePlayer.Location.Y)
            if (name.Location.Y < xePlayer.Location.Y)
            {
                //if (y_computer[0] + xeComputer1.Height == y_Player)
                if (name.Location.Y + name.Height >= xePlayer.Location.Y)
                {
                    if (xePlayer.Location.X >= name.Location.X - xePlayer.Width && xePlayer.Location.X <= name.Location.X + xePlayer.Width)
                    //if(x_Player >= x_computer[0] - xePlayer.Width && x_Player <= x_computer[0] + xePlayer.Width)
                    {
                        xeComputer3.Visible = false;
                        xeComputer4.Visible = false;
                        TimerXe2.Stop();
                        timerDiChuyenXe.Stop();
                        TimerBGR.Stop();
                        TimerXe3.Stop();
                        TimerXe4.Stop();
                        VuNo1.Visible    = true;
                        VuNo1.Location   = new Point(xePlayer.Location.X, xePlayer.Location.Y);
                        VuNo2.Visible    = true;
                        VuNo2.Location   = new Point(xePlayer.Location.X, xePlayer.Location.Y);
                        VuNo3.Visible    = true;
                        VuNo3.Location   = new Point(xePlayer.Location.X, xePlayer.Location.Y);
                        VuNo4.Visible    = true;
                        VuNo4.Location   = new Point(xePlayer.Location.X, xePlayer.Location.Y);
                        xePlayer.Visible = false;
                        name.Visible     = false;
                        //timerDiChuyenXe.Stop();
                        //TimerBGR.Stop();

                        Thread.Sleep(100);
                        DialogResult luachon = MessageBox.Show("Bạn có muốn chơi tiếp không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (luachon == DialogResult.Yes)
                        {
                            diem           = 0;
                            lblDiemSo.Text = diem.ToString();

                            // CHơi lại từ đâu
                            // CHơi lại từ đâu
                            timerDiChuyenXe.Start();
                            TimerBGR.Start();
                            TimerXe2.Start();
                            //TimerXe3.Start();
                            //TimerXe4.Start();
                            KiemTraNhan      = false;
                            VuNo1.Visible    = false;
                            VuNo2.Visible    = false;
                            VuNo3.Visible    = false;
                            VuNo4.Visible    = false;
                            xePlayer.Visible = true;
                            name.Visible     = true;
                            y_computer[y]    = 0;
                            Random rd = new Random();
                            x_computer[x] = rd.Next(95, this.Width - 95 - name.Width);
                            name.Location = new Point(x_computer[x], y_computer[y]);
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                }
            }
        }