title: How to do fast smooth animation in C# using WPF
body: <p>I'm currently programming a game of Pong. I have the majority of the game completed but I've run into an annoying problem. I'm using a <code>dispatcherTimer</code> with priority set to Send and time span set to 1 millisecond. I'm animating the rectangle using up to dx=9 and dy=9 in order to make the ball move fast enough. Because of the large pixel jumps the ball appears skip across the screen instead of a smooth travel. According to math in 1 millisecond per cycle this ball should be moving MUCH faster than it is. I need to update the ball more often and move it by less...</p>
  
  <p>Are there any suggestions on a better method to do this? Here is a snippet of what I have...</p>
  
  <pre><code>pongballTimer = new DispatcherTimer(DispatcherPriority.Send);
  pongballTimer.Tick += new EventHandler(pongballTimer_Tick);
  pongballTimer.Interval = new TimeSpan(0, 0, 0, 0, _balldt);
  
  private void pongballTimer_Tick(object sender, EventArgs e)
  {
     double pongtop = Canvas.GetTop(PongBall);
     double pongleft = Canvas.GetLeft(PongBall);
     double paddletop = Canvas.GetTop( RightPaddle );
     double paddleleft = Canvas.GetLeft( RightPaddle );
  
     if (pongleft + PongBall.Width &gt; paddleleft)
     {
        if (((pongtop &lt; paddletop + RightPaddle.Height) &amp;&amp; (pongtop &gt; paddletop)) ||
           ((pongtop + PongBall.Height &lt; paddletop + RightPaddle.Height) &amp;&amp;
           (pongtop + PongBall.Height &gt; paddletop)))
        { 
           _dx *= -1;
           SetBalldy(pongtop, PongBall.Height, paddletop, RightPaddle.Height);
           _rightpoint++;
           lblRightPoint.Content = _rightpoint.ToString();
           meHitSound.Play();
        }
  
        else // The ball went past the paddle without a collision
        {
           RespawnPongBall(true); 
           _leftpoint++;
           lblLeftPoint.Content = _leftpoint.ToString();
           meMissSound.Play();
  
           if (_leftpoint &gt;= _losepoint)
                 LoseHappened("You Lost!!");
                 return; 
        }
     }
  
     if (pongleft &lt; 0)
     {
        meHitSound.Play();
        _dx *= -1;
     }
  
     if (pongtop &lt;= _linepady ||
           pongtop + PongBall.Height &gt;= PongCanvas.Height - _linepady)
     {
        meDeflectSound.Play();
        _dy *= -1;
     }
     Canvas.SetTop(PongBall, pongtop + _dy);
     Canvas.SetLeft(PongBall, pongleft + _dx);
  }
  </code></pre>