title: DeltaTime issue at program start
body: <p>i have a problem with deltaTime ive been using. My Code is the following:</p>
  
  <pre><code>public class Time {
      public static float deltaTime = 0;                      
      public static long frameCount = 0;                      
      public static float fixedTime = 0;                     
      public static float fixedDeltaTime = 0.1f;      
      public static float maxDeltaTime = 0.25f;       
  </code></pre>
  
  <p>}</p>
  
  <p>And now in my MainThread.java in my run() function:</p>
  
  <pre><code> while (running) {
          canvas = null;
          try {
              canvas = this.surfaceHolder.lockCanvas();
              synchronized (surfaceHolder) {
                  float newTime = System.nanoTime() / 1000000000.0f;
                  Time.deltaTime = frameTime = newTime - currentTime;
  
                  if(frameTime &gt; Time.maxDeltaTime)
                          frameTime = Time.maxDeltaTime;
  
                  currentTime = newTime;
  
                  accumulator += frameTime;
  
                  while(accumulator &gt; Time.fixedDeltaTime)
                  { 
                          this.gamePanel.update();   // where the player and my enemy gets updated                         
                          accumulator -= Time.fixedDeltaTime;
                  }
  
                  this.gamePanel.render(canvas);
                  //Perform all non-physics-related updates here
  
  
                  ++Time.frameCount;
  
                  framesSkipped = 0;  // resetting the frames skipped
  
                  timeDiff = System.currentTimeMillis() - beginTime;
                  // calculate sleep time
                  sleepTime = (int)(FRAME_PERIOD - timeDiff);
  
                      if (sleepTime &gt; 0) {
                              // if sleepTime &gt; 0 we're OK
                              try {
                                      Thread.sleep(sleepTime);    
                              } catch (InterruptedException e) {}
                      }
  
                      while (sleepTime &lt; 0 &amp;&amp; framesSkipped &lt; MAX_FRAME_SKIPS) {
                              // we need to catch up
                              this.gamePanel.update(); // update without rendering
                              sleepTime += FRAME_PERIOD;  // add frame period to check if in next frame
                              framesSkipped++;
                      }
  
                      if (framesSkipped &gt; 0) {
  
                              Log.d(TAG, "Skipped:" + framesSkipped);
                      }
                              // for statistics
                              framesSkippedPerStatCycle += framesSkipped;
                              // calling the routine to store the gathered statistics
                              storeStats();
                  }
              } finally {
                  // in case of an exception the surface is not left in
                  // an inconsistent state
                      if (canvas != null) {
                      surfaceHolder.unlockCanvasAndPost(canvas);
                      }
              } //end finally
  
      } 
  </code></pre>
  
  <p>}</p>
  
  <p>in the gamePanel.update() ive got the update calls for the player and my enemy.
  Now my Problem is, that at the start of my game the deltaTime is extremly high und thus my movement is very fast, because i have the following in my enemy class in the update method:</p>
  
  <pre><code>                   x += vX * Time.deltaTime; // velocity * deltaTime
                     y -= vY * Time.deltaTime;
                     //Log.d(TAG, "Time:"+Time.deltaTime+" x: "+x+" y: "+y);
                     vY -= gravity;
  </code></pre>
  
  <p>Am i doing it right, or is something wrong with my structure?
  Thanks for any help.</p>