Exemple #1
0
 public Form1()
 {
     InitializeComponent();
     pictureBox1.Location = new Point(0, 0);
     pictureBox1.Width    = this.Width - 16;
     for (int j = 0; j < n; j++)
     {
         btn[j] = new Button();
     }
     Startpage.BringToFront();
     btnStart.BringToFront();
     btnAbout.BringToFront();
     btnQuit.BringToFront();
     try
     {
         string[] str = File.ReadAllText(fpath).Split('#');
         lblScore.Text = "Ball: " + str[0] + "    Point: " + str[1];
     }
     catch
     {
         Directory.CreateDirectory("C:\\Program Files/Swipe Brick Breaker");
         File.Create(fpath);
     }
     sound = new SoundPlayer(MyResource.back);
     sound.PlayLooping();
 }
Exemple #2
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     sound = new SoundPlayer(MyResource.back);
     sound.PlayLooping();
     btnOk.Visible     = false;
     lblResult.Visible = false;
     Startpage.Visible = true;
     btnStart.Visible  = true;
     btnAbout.Visible  = true;
     btnQuit.Visible   = true;
     listPic.Clear();
     listTime.Clear();
     PPic.Clear();
     xb.Clear();
     yb.Clear();
     kxb.Clear();
     kyb.Clear();
     x1.Clear();
     y1.Clear();
     kx.Clear();
     ky.Clear();
     t.Tick -= new EventHandler(timer2_Tick);
     this.Controls.Clear();
     this.Controls.Add(Startpage);
     this.Controls.Add(btnStart);
     this.Controls.Add(btnAbout);
     this.Controls.Add(btnQuit);
     this.Controls.Add(pictureBox1);
     this.Controls.Add(lblBall_);
     this.Controls.Add(lblPoint_);
     this.Controls.Add(lblBall);
     this.Controls.Add(lblPoint);
     this.Controls.Add(btnOk);
     this.Controls.Add(lblResult);
     this.Controls.Add(lblScore1);
     this.Controls.Add(lblScore);
     this.Controls.Add(btnContinue);
     Startpage.BringToFront();
     btnStart.BringToFront();
     btnAbout.BringToFront();
     btnQuit.BringToFront();
 }
Exemple #3
0
 public Form1()
 {
     InitializeComponent();
     bw = pictureBox1.Width / 10;
     bh = bw / 2;
     for (int j = 0; j < n; j++)
     {
         if (j % 8 == 0)
         {
             k++;
         }
         btn[j] = new Button();
         btn[j].SetBounds(j % 8 * bw + bw, k * bh, bw, bh);
         btn[j].Text      = "";
         btn[j].BackColor = Color.Blue;
         btn[j].Enabled   = false;
         this.Controls.Add(btn[j]);
         btn[j].BringToFront();
     }
     Startpage.BringToFront();
     btnStart.BringToFront();
     btnQuit.BringToFront();
     pictureBox2.Location = new Point(r.Next(0, pictureBox1.Width - 30), r.Next(100, 300));
 }
Exemple #4
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     if (y < pictureBox1.Height)
     {
         for (int j = 0; j < n; j++)
         {
             if (btn[j].Visible)
             {
                 if (x == btn[j].Location.X + bw && y <= btn[j].Location.Y + bh && y + pich >= btn[j].Location.Y - pich)
                 {
                     xb             = true;
                     btn[j].Visible = false;
                     ball++;
                 }
                 if (x + picw == btn[j].Location.X && y <= btn[j].Location.Y + bh && y + pich >= btn[j].Location.Y)
                 {
                     xb             = false;
                     btn[j].Visible = false;
                     ball++;
                 }
                 if (y == btn[j].Location.Y + bh && x <= btn[j].Location.X + bw && x >= btn[j].Location.X - picw)
                 {
                     yb             = true;
                     btn[j].Visible = false;
                     ball++;
                 }
                 if (y + pich == btn[j].Location.Y && x <= btn[j].Location.X + bw && x >= btn[j].Location.X - picw)
                 {
                     yb             = false;
                     btn[j].Visible = false;
                     ball++;
                 }
                 lblBall.Text = Convert.ToString(ball);
             }
             else
             {
                 if (ball == n)
                 {
                     ball = 0;
                     while (i > 0)
                     {
                         t.Tick -= new EventHandler(timer1_Tick);
                         i--;
                     }
                     MessageBox.Show("YOU WIN");
                     Startpage.Visible = true;
                     Startpage.BringToFront();
                     btnStart.Visible = true;
                     btnStart.BringToFront();
                     btnQuit.Visible = true;
                     btnQuit.BringToFront();
                 }
             }
         }
         pictureBox2.Location = new Point(x, y);
         if (x == 0)
         {
             xb = true;
         }
         if (x == pictureBox1.Width - pictureBox2.Width)
         {
             xb = false;
         }
         if (y == 0)
         {
             yb = true;
         }
         if (y + pictureBox2.Height == button1.Location.Y && x + pictureBox2.Width / 2 <= button1.Location.X + button1.Width && x + pictureBox2.Width / 2 >= button1.Location.X)
         {
             yb = false;
             fastcount++;
             if (fastcount == 2)
             {
                 fastcount = 0;
                 i++;
                 t.Tick += new EventHandler(timer1_Tick);
                 t.Start();
             }
         }
         if (y + pictureBox2.Height == button1.Location.Y && x + pictureBox2.Width / 2 <= button1.Location.X && x + pictureBox2.Width / 2 >= button1.Location.X - pictureBox2.Width / 2)
         {
             yb = false;
             xb = false;
             fastcount++;
             if (fastcount == 2)
             {
                 fastcount = 0;
                 i++;
                 t.Tick += new EventHandler(timer1_Tick);
                 t.Start();
             }
         }
         if (y + pictureBox2.Height == button1.Location.Y && x + pictureBox2.Width / 2 <= button1.Location.X + button1.Width + pictureBox2.Width / 2 && x + pictureBox2.Width / 2 >= button1.Location.X + button1.Width)
         {
             yb = false;
             xb = true;
             fastcount++;
             if (fastcount == 2)
             {
                 fastcount = 0;
                 i++;
                 t.Tick += new EventHandler(timer1_Tick);
                 t.Start();
             }
         }
         x = xb ? x + 1 : x - 1;
         y = yb ? y + 1 : y - 1;
     }
     else
     {
         y = 293;
         while (i > 0)
         {
             t.Tick -= new EventHandler(timer1_Tick);
             i--;
         }
         MessageBox.Show("GAME OVER");
         Startpage.Visible = true;
         Startpage.BringToFront();
         btnStart.BringToFront();
         btnStart.Visible = true;
         btnQuit.Visible  = true;
         btnQuit.BringToFront();
     }
 }