Пример #1
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.A)
            {
                cue.Expand(0.1);
            }
            if (e.KeyCode == Keys.D)
            {
                cue.Expand(-0.1);
            }
            if (e.KeyCode == Keys.C)
            {
                cue.ChangeOwner(NextBall(cue.Owner.Numb));
            }
            if (e.KeyCode == Keys.F)
            {
                if (HitMode)
                {
                    DoHit(); HitMode = false;
                }
                else
                {
                    bo        = new BallOut("Шары не остановились");
                    shtr.Text = shtr.Text.Replace(minus.ToString(), (minus + 50).ToString()); minus += 50;
                    bo.Owner  = this;
                    bo.Show();
                }
            }
            if (e.KeyCode == Keys.L)
            {
                EndOfGame();
            }
            if (e.KeyCode == Keys.Escape)
            {
                TIMER.Stop();

                Menu m = new Menu(pictureBox1.Image); m.Owner = this;
                m.ShowDialog();
                if (m.DialogResult == DialogResult.Cancel)
                {
                    this.Close();
                }
                if (m.DialogResult == DialogResult.Retry)
                {
                    VisibleData(true); StartingPosition(); HitMode = true;
                }

                TIMER.Start();
            }

            if (e.KeyCode == Keys.Up || e.KeyCode == Keys.Right)
            {
                if (TimeSpeed < 5)
                {
                    timelabel.Text = timelabel.Text.Replace((char)(TimeSpeed + 48), (char)(TimeSpeed * 2 + 48)); TimeSpeed *= 2;
                }
            }
            if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Left)
            {
                if (TimeSpeed > 1)
                {
                    timelabel.Text = timelabel.Text.Replace((char)(TimeSpeed + 48), (char)(TimeSpeed / 2 + 48)); TimeSpeed /= 2;
                }
            }
        }
Пример #2
0
 private void DrawToBuffer(Graphics g, double k)
 {
     for (int i = 0; i < Objects.Count; i++)
     {
         for (int j = i + 1; j < Objects.Count; j++)
         {
             if (Ball.Collided(Objects[i], Objects[j]))
             {
                 Ball.Collision(Objects[i], Objects[j]);
             }
         }
     }
     for (int i = 0; i < Objects.Count; i++)
     {
         Objects[i].Move(k * 3);
         if (!NearLose(Objects[i]))
         {
             Objects[i].Borders(pictureBox1.Width - 110, pictureBox1.Height - 110, new Point {
                 X = CoordinatesDelta.X - 50, Y = CoordinatesDelta.Y - 50
             }
                                , k);
             if (Objects[i].OutOfBorders(pictureBox1.Width - 110, pictureBox1.Height - 110, new Point {
                 X = CoordinatesDelta.X - 50, Y = CoordinatesDelta.Y - 50
             }
                                         , k * 3))
             {
                 Objects.Remove(Objects[i]);
                 bo        = new BallOut("Мяч вылетел"); bo.Owner = this;
                 shtr.Text = shtr.Text.Replace(minus.ToString(), (minus + 100).ToString()); minus += 100;
                 bo.Show();
                 cue.Owner = NextBall(cue.Owner.Numb);
                 DoLessNumb(i);
                 i--;
                 continue;
             }
         }
         else
         {
             if (Objects[i] != bitok)
             {
                 bo        = new BallOut("Мяч попал в лузу"); bo.Owner = this;
                 Plus.Text = Plus.Text.Replace(plus.ToString(), (plus + 100).ToString()); plus += 100;
             }
             else
             {
                 bo        = new BallOut("Биток попал в лузу"); bo.Owner = this;
                 shtr.Text = shtr.Text.Replace(minus.ToString(), (minus + 100).ToString()); minus += 50;
                 Plus.Text = Plus.Text.Replace(plus.ToString(), (plus + 100).ToString()); plus += 100;
             }
             Objects.Remove(Objects[i]);
             bo.Show();
             cue.Owner = NextBall(cue.Owner.Numb);
             DoLessNumb(i);
             i--;
             continue;
         }
     }
     if (BallsStop())
     {
         this.HitMode = true; cue.ChangeOwner(cue.Owner);
     }
     if (Objects.Count == 0)
     {
         MessageBox.Show(this, "");
     }
     g.FillRectangle(sb, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height));
     g.DrawImage(global::Billi.Properties.Resources.table3, 0, 0, pictureBox1.Width, pictureBox1.Height);
     ToDrawAll(g, 3);
 }