示例#1
0
 public Linear(VectorInt aCurrent, VectorInt aTarget, VectorDouble aStep, bool useBounce)
 {
     _Start = new VectorDouble(aCurrent.X, aCurrent.Y);
     _Current = new VectorDouble(aCurrent.X, aCurrent.Y);
     _Target = _Start.Add(aTarget.ToVectorDouble());
     _Step = aStep;
     _Bounce = useBounce;
 }
示例#2
0
        public VectorDouble GetPhysFromLogical(VectorInt i)
        {
            var v = grid.Children[0] as Image;

            var s = new VectorDouble(grid.ColumnDefinitions.First().ActualWidth,
                                  grid.RowDefinitions.First().ActualHeight);
            return new VectorDouble(i.X, i.Y).Multiply(s).Add( s.Divide(new VectorDouble(2,2))) ;
        }
示例#3
0
 public VectorInt getNext()
 {
     _Current = _Current.Add(_Step);
     if (_Bounce)
     {
         if (_Current.X >= _Target.X) _Step.X *= -1;
         if (_Current.X <= _Start.X) _Step.X *= -1;
         if (_Current.Y >= _Target.Y) _Step.Y *= -1;
         if (_Current.Y <= _Start.Y) _Step.Y *= -1;
         return _Current.ToVectorInt();
     }
     else
     {
         if (_Current == _Target) return null;
         return _Current.ToVectorInt();
     }
 }
示例#4
0
        public void Step()
        {
            if (elements == null) return;

            foreach (var e in elements)
            {
                var p = new VectorDouble(Canvas.GetLeft(e.Target), Canvas.GetTop(e.Target));
                if (p.X + e.Speed.X > container.ActualWidth - e.Size.X) e.Speed.X *= -1;
                if (p.X + e.Speed.X < 0) e.Speed.X *= -1;

                if (p.Y + e.Speed.Y > container.ActualHeight - e.Size.Y) e.Speed.Y *= -1;
                if (p.Y + e.Speed.Y < 0) e.Speed.Y *= -1;

                Canvas.SetLeft(e.Target, p.X + e.Speed.X);
                Canvas.SetTop(e.Target, p.Y + e.Speed.Y);

                e.Spin += e.SpinSpeed;

                e.Target.RenderTransform = new RotateTransform(e.Spin);
            }
        }
示例#5
0
 public VectorDouble Divide(VectorDouble value)
 {
     return new VectorDouble(x / value.X, y / value.Y);
 }
示例#6
0
 public VectorDouble Add(VectorDouble value)
 {
     return new VectorDouble(x + value.X, y + value.Y);
 }
示例#7
0
 public VectorDouble(VectorDouble copy)
 {
     this.x = copy.x;
     this.y = copy.y;
 }
示例#8
0
 public VectorDouble Subtract(VectorDouble value)
 {
     return new VectorDouble(x - value.X, y - value.Y);
 }
示例#9
0
 public VectorDouble Multiply(VectorDouble value)
 {
     return new VectorDouble(x * value.X, y * value.Y);
 }