Example #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();
 }
        private void Back_Click(object sender, EventArgs e)
        {
            Startpage startpage = this.Owner as Startpage;

            startpage.Visible = true;
            Close();
        }
        public ApplicationVM()
        {
            Pages.Add(new BestellingVM());
            Pages.Add(new InstellingenVM());
            Startpage.Add(new PageOneVM());
            // Add other pages

            CurrentPage = Startpage[0];
        }
Example #4
0
 private void btnContinue_Click(object sender, EventArgs e)
 {
     isover      = false;
     falledcount = 0;
     Startpage.SendToBack();
     btnContinue.Visible = false;
     lblResult.Visible   = false;
     btnOk.Visible       = false;
 }
Example #5
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();
 }
Example #6
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));
 }
Example #7
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();
     }
 }
Example #8
0
 private void btnStart_Click_1(object sender, EventArgs e)
 {
     sound = new SoundPlayer(MyResource.start);
     sound.PlayLooping();
     k              = -1;
     isover         = false;
     lblBall_.Text  = "0";
     lblPoint_.Text = "0";
     falledcount    = 0;
     Startpage.SendToBack();
     btnStart.Visible = false;
     btnAbout.Visible = false;
     btnQuit.Visible  = false;
     bw = pictureBox1.Width / 10;
     bh = bw;
     for (int j = 0; j < n; j++)
     {
         if (j % 10 == 0)
         {
             k++;
         }
         btn[j].SetBounds(j % 10 * bw, k * bh, bw, bh);
         btn[j].Tag       = j;
         btn[j].Font      = new Font("Algerian", 18F, FontStyle.Bold);
         btn[j].ForeColor = Color.White;
         try
         {
             btn[j].Image = MyResource.btnimage;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
         btn[j].FlatStyle = FlatStyle.Standard;
         btn[j].UseVisualStyleBackColor = true;
         btncount[j] = 0;
         btn[j].Text = "";
         btn[j].Name = "btn" + j.ToString();
         this.Controls.Add(btn[j]);
         btn[j].MouseDown += new MouseEventHandler(button_MouseDown);
         btn[j].BringToFront();
     }
     listPic.Add(new PictureBox());
     listPic[0].BackgroundImage       = MyResource.ballimage;
     listPic[0].BackgroundImageLayout = ImageLayout.Stretch;
     listPic[0].Width    = picw;
     listPic[0].Height   = pich;
     listPic[0].Location = new Point(0, pictureBox1.Height - pich);
     this.Controls.Add(listPic[0]);
     listPic[0].BringToFront();
     listTime.Add(new Timer());
     listTime[0].Interval = 1;
     t.Interval           = 1;
     t.Tick += new EventHandler(timer2_Tick);
     i++;
     PPic.Add(new Point(listPic[0].Location.X, listPic[0].Location.Y));
     button = 0;
     xb.Add(true);
     yb.Add(false);
     kxb.Add(false);
     kyb.Add(false);
     x1.Add(1);
     y1.Add(1);
     kx.Add(1);
     ky.Add(1);
     stacount = 0;
     for (int j = 0; j < n; j++)
     {
         if (j < 10)
         {
             btncount[j]    = 1;
             btn[j].Text    = "1";
             btn[j].Visible = true;
         }
         else
         {
             btn[j].Visible = false;
         }
     }
 }