diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-07-15 16:57:49 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-07-15 16:57:49 +0200 |
commit | 6297e7f94eeee16f008db592c4e944df3c05299e (patch) | |
tree | 8e968be3d6cd656b3076a7bd203ccd046cb88d5e /core/src | |
parent | a20b6a9d960b68e1818d6688c84b989808618b60 (diff) | |
download | RustAndDust-6297e7f94eeee16f008db592c4e944df3c05299e.zip RustAndDust-6297e7f94eeee16f008db592c4e944df3c05299e.tar.gz |
GameCamera: code cleanup
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/creepingarmor/screens/GameCamera.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/core/src/ch/asynk/creepingarmor/screens/GameCamera.java b/core/src/ch/asynk/creepingarmor/screens/GameCamera.java index c97234a..339a26e 100644 --- a/core/src/ch/asynk/creepingarmor/screens/GameCamera.java +++ b/core/src/ch/asynk/creepingarmor/screens/GameCamera.java @@ -55,14 +55,17 @@ public class GameCamera extends OrthographicCamera float diff = (viewportAspect - aspect); if (diff < -ZEROF) { + // wider than tall window.width = java.lang.Math.min((screenHeight * viewportAspect / zoom), screenWidth); window.height = screenHeight; window.x = ((screenWidth - window.width) / 2f); window.y = 0f; + viewportWidth = (viewportHeight * (window.width / window.height)); hud.y = hudCorrection; hud.x = (hud.y * viewportWidth / viewportHeight); - viewportWidth = (viewportHeight * (window.width / window.height)); } else if (diff > ZEROF) { + // taller than wide + // FIXME fix hud vertical position window.width = screenWidth; window.height = java.lang.Math.min((screenWidth * viewportAspect / zoom), screenHeight); window.x = 0f; @@ -71,19 +74,20 @@ public class GameCamera extends OrthographicCamera hud.x = hudCorrection; hud.y = (hud.x / viewportWidth * viewportHeight); } + hud.width = (window.width - (2 * hud.x)); hud.height = (window.height - (2 * hud.y)); - Gdx.gl.glViewport((int)window.x, (int)window.y, (int)window.width, (int)window.height); - - this.widthFactor = (viewportWidth / screenWidth); - this.heightFactor = (viewportHeight / screenHeight); + widthFactor = (viewportWidth / screenWidth); + heightFactor = (viewportHeight / screenHeight); clampPosition(); update(true); hudMatrix.setToOrtho2D(hud.x, hud.y, hud.width, hud.height); hudInvProjMatrix.set(hudMatrix); Matrix4.inv(hudInvProjMatrix.val); + + Gdx.gl.glViewport((int)window.x, (int)window.y, (int)window.width, (int)window.height); } public Matrix4 getHudMatrix() |