How do I implement a camera in my 2d java game?

Im creating a platform game in java. the issue I have right now is implementing the camera that will follow the player rather than making the background scroll. Could someone please enlighten me as to how I can implement this thanks!
public class Camera {

private float x, y;

public Camera(float x, float y) {
    this.x = x;
    this.y = y;
}

public void cameraMove(Player player) {
    x = -player.x + SideScroller.WIDTH/2;
    y = -player.y + SideScroller.HEIGHT/2;
}

public float getX() {
    return x;
}

public void setX(float x) {
    this.x = x;
}

public float getY() {
    return y;
}

public void setY(float y) {
    this.y = y;
}

}
How can I use this code or revise it to use it in my game class?

Комментарии

Популярные сообщения из этого блога

Skipping acquire of configured file 'contrib/binary-i386/Packages' as repository … doesn't support architecture 'i386'

FillChar and StringOfChar under Delphi 10.2 for Win64 Release Target

Python Selenium - How to configure a client certificate file while initializing PhantomJS driver instance