summaryrefslogtreecommitdiff
path: root/core/src/org/snoopdesigns/endless/physics/camera/CameraContext.java
blob: 635813c7ade4ef85739135644ca10b00d27ea21a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package org.snoopdesigns.endless.physics.camera;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Vector2;

public final class CameraContext {

    private static final float DEFAULT_WORLD_WIDTH = 300.0f;

    private final Vector2 position;
    private final Vector2 viewport;
    private float zoom;
    private Matrix4 cameraProjection;

    public CameraContext() {
        final float w = Gdx.graphics.getWidth();
        final float h = Gdx.graphics.getHeight();

        this.position = new Vector2(0, 0);
        this.zoom = 1.0f;
        this.viewport = new Vector2(DEFAULT_WORLD_WIDTH, DEFAULT_WORLD_WIDTH * (h / w));
    }

    public Matrix4 getCameraProjection() {
        return cameraProjection;
    }

    public void setCameraProjection(Matrix4 cameraProjection) {
        this.cameraProjection = cameraProjection;
    }

    public Vector2 getPosition() {
        return position;
    }

    public float getZoom() {
        return zoom;
    }

    public void setZoom(float zoom) {
        this.zoom = zoom;
    }

    public Vector2 getViewport() {
        return viewport;
    }
}