title: solved 2d game camera follow with translate, im having trouble articulating in my mind how it works, what is keeping camera centered on the player?
body: <p>I got something working but cannot interpret in my mind, how is it painting every picture with the player in the middle by taking its original position away from where it is painting everything, my brain is addled.</p>
  
  <p>I would like to know why it is working</p>
  
  <pre><code>public static Integer ufox = 102,ufoy = 115;
  
  
  public void paint (Graphics g){
      g.clearRect(0,0,1000,1000);
      g.translate(-ufox+102,-ufoy+115);
      g.setColor(Color.WHITE);
      g.fillRect(0, 0, 1000, 1000);
      //backround enemies etc
      g.setColor(Color.BLUE);
      g.drawString(ufo,ufox,ufoy);//this is the player!
      g.setColor(Color.GREEN);
  }
  
  
  public void run() {
      while(true){
          ufox=//game logic
          ufoy=//game logic
          try{Thread.sleep(20);}catch(Exception e){}  
          repaint();  
      }
  }
  
  //key listener and main...
  </code></pre>