title: Java Game Animations are very slow and unclear
body: <p>In my Java Game, which should get an AirForce, i have simple moving animations, for the player, the missiles, and the enemys. </p>
  
  <p>My Problem is, these Animations are very slow. Not slow as usual, but it seems like the animation happens, and the programme is waiting for something.. but what - i dont know. 
  Also it isnt the sleep time - when i reduce it, it shows the same but faster. 
  so mooooooove - stop - moooooooove - stop, and this very fast. </p>
  
  <p>So, here the important code, where i move the JPanels: (which are containing the pictures)</p>
  
  <pre><code>public void run(){
      while(running){
          if(!pause){
              System.out.println(timeSinceLastFrame);
              updateTimes();
              handleMissiles();
              handlePlayer();
              handleEnemys();
              repaint();
              try{Thread.sleep(10);}catch(InterruptedException e){}
          }
      }
  }
  
  public void updateTimes(){
      thisFrame = System.currentTimeMillis();
      timeSinceLastFrame = ((float) (thisFrame-lastFrame)/1000f);
      lastFrame=thisFrame;
      timeSinceLastMissile++;
  }
  
  public void handleMissiles(){
      for(int i = 0; i &lt; missiles.size(); i++){
          Missile m = missiles.get(i);
          m.setX((int) (m.getX() * 1.02 + 1));
          m.resetPosition();
          if(m.isUnused()){
              gameField.remove(m);
              missiles.remove(m);
          }
      }
  }
  
  public void handlePlayer(){
      if(flyUp){ player.fly(0); } 
      if(flyRight){ player.fly(1); }
      if(flyDown){ player.fly(2); }
      if(flyLeft){ player.fly(3); }
      if(shoot){ shoot(); }
  }
  
  public void handleEnemys(){
      for(int i = 0; i &lt; enemys.size(); i++){
          Enemy e = enemys.get(i);
          e.setX((int) (e.getX() - e.speedX));
          e.resetPosition();
          if(e.isDestroyed()){
              gameField.remove(e);
              enemys.remove(e);
          }
      }
  }
  </code></pre>
  
  <p>The player fly method looks like this:</p>
  
  <pre><code>public void fly(int dir){
      switch(dir){
          case 0: flyUp(); break;
          case 1: flyRight(); break;
          case 2: flyDown(); break;
          case 3: flyLeft(); break;
      }
      resetPosition();
  }
  
  public void flyUp(){
      if(y &gt; 0){
          setY(getY() - 3);
      }
  }
  public void flyRight(){
      if(x &lt; frameWidth - width - 10){
          setX(getX() + 3);
      }
  }   
  public void flyDown(){
      if(y &lt; frameHeight - height - 30){
          setY(getY() + 3);
      }
  }   
  public void flyLeft(){
      if(x &gt; 0){
          setX(getX() - 3);
      }
  }
  </code></pre>
  
  <p>Reset position is nothing special:</p>
  
  <pre><code>public void resetPosition(){
      setBounds(x, y, width, height);
  }
  </code></pre>