summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-30 16:29:16 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-30 16:29:16 +0200
commit9507c5fcce6f5b41b167ce200692111b00457600 (patch)
tree6627f45a5ab87dab0436d64781bfdef417f330c8 /core/src/ch/asynk/tankontank
parent79d7809c3067245cf877c3b8f81b0ff5b82f5850 (diff)
downloadRustAndDust-9507c5fcce6f5b41b167ce200692111b00457600.zip
RustAndDust-9507c5fcce6f5b41b167ce200692111b00457600.tar.gz
GameScreen: add virtualWidth, virtualHeight
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