summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r--core/src/ch/asynk/tankontank/screens/GameScreen.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java
index 82a92a0..6169509 100644
--- a/core/src/ch/asynk/tankontank/screens/GameScreen.java
+++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java
@@ -46,6 +46,8 @@ public class GameScreen implements Screen
private static final int DRAGGED_Z_INDEX = 10;
private float maxZoomOut;
+ private float virtualWidth;
+ private float virtualHeight;
private final OrthographicCamera cam;
private final FitViewport mapViewport;
@@ -76,11 +78,13 @@ public class GameScreen implements Screen
fps.setPosition( 10, Gdx.graphics.getHeight() - 40);
map = factory.getMap(game.manager, GameFactory.MapType.MAP_A);
+ virtualWidth = map.getWidth();
+ virtualHeight = map.getHeight();
mapBatch = new SpriteBatch();
- cam = new OrthographicCamera();
+ cam = new OrthographicCamera(virtualWidth, virtualHeight);
cam.setToOrtho(false);
- mapViewport = new FitViewport(map.getWidth(), map.getHeight(), cam);
+ mapViewport = new FitViewport(virtualWidth, virtualHeight, cam);
mapViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
debugShapes = new ShapeRenderer();
@@ -184,8 +188,8 @@ public class GameScreen implements Screen
{
float cx = cam.viewportWidth * cam.zoom / 2f;
float cy = cam.viewportHeight * cam.zoom / 2f;
- cam.position.x = MathUtils.clamp(cam.position.x, cx, (map.getWidth() - cx));
- cam.position.y = MathUtils.clamp(cam.position.y, cy, (map.getHeight() - cy));
+ cam.position.x = MathUtils.clamp(cam.position.x, cx, (virtualWidth - cx));
+ cam.position.y = MathUtils.clamp(cam.position.y, cy, (virtualHeight - cy));
}
@Override