public void draw(Graphics g, Entity avatar) { // Get the players's WORLD coords float px = (int) (avatar.getX())*tileWidth; float py = (int) (avatar.getY())*tileHeight; // We want to draw the player at center screen, so make it happen // The problem is that 0,0 is in the top left corner. // So, we need to offset him DOWN and to the LEFT // centerX really isn't the center, its what we translate to to draw // the player in the center. float centerx = px - xoffset; float centery = py - yoffset; // Draw entities // TODO: Only draw entites visible and close to edges g.translate(centerx, centery); avatar.image.draw(px, py); g.resetTransform();