Beispiel #1
0
 protected Bola(PontoD posicao, double raio, double xVelocidade, double yVelocidade)
 {
     this.X           = posicao.X;
     this.Y           = posicao.Y;
     this.Raio        = raio;
     this.Massa       = raio * 2.5;
     this.XVelocidade = xVelocidade;
     this.YVelocidade = yVelocidade;
 }
Beispiel #2
0
 public BolaWPF(PontoD position, double xVelocity, double yVelocity, double radius, Brush fill) : base(position, radius, xVelocity, yVelocity)
 {
     this.WpfShape = new Ellipse
     {
         Width  = radius * 2,
         Height = radius * 2,
         Fill   = fill
     };
 }
        private void BotaoAddBola_Click(object sender, RoutedEventArgs e)
        {
            Color?color = this.ColorPickerColor.SelectedColor;

            if (color == null)
            {
                MessageBox.Show("Por favor, selecione uma cor!");
                return;
            }
            int?radius = this.IntegerUpDownRadius.Value;

            if (radius != null)
            {
                PontoD position = this._world.GetPosicaoNaoOcupada((double)radius);
                Tuple <double, double> speed = this._world.GetRandomVelocidade(-1, 1);

                this._world.AddObjeto(new BolaWPF(position, speed.Item1, speed.Item2, (double)radius,
                                                  GetBrushFromColor((Color)color)));
            }
            else
            {
                MessageBox.Show("Por favor, adicionar o raio.");
            }
        }