summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/screens
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-06-30 06:21:50 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2015-06-30 06:21:50 +0200
commitd74bcf9bf390418df35d94b54d59df0170033f65 (patch)
tree2ceae1bd287c42b4f109c47d2360199d6076a156 /core/src/ch/asynk/tankontank/screens
parent06868b70f82ed30e46ea3fd012a0befc8380bbad (diff)
downloadRustAndDust-d74bcf9bf390418df35d94b54d59df0170033f65.zip
RustAndDust-d74bcf9bf390418df35d94b54d59df0170033f65.tar.gz
TankOnTank -> CreepingArmor
Diffstat (limited to 'core/src/ch/asynk/tankontank/screens')
-rw-r--r--core/src/ch/asynk/tankontank/screens/GameCamera.java188
-rw-r--r--core/src/ch/asynk/tankontank/screens/GameScreen.java217
-rw-r--r--core/src/ch/asynk/tankontank/screens/MenuCamera.java113
-rw-r--r--core/src/ch/asynk/tankontank/screens/MenuScreen.java264
4 files changed, 0 insertions, 782 deletions
diff --git a/core/src/ch/asynk/tankontank/screens/GameCamera.java b/core/src/ch/asynk/tankontank/screens/GameCamera.java
deleted file mode 100644
index 52ef271..0000000
--- a/core/src/ch/asynk/tankontank/screens/GameCamera.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package ch.asynk.tankontank.screens;
-
-import com.badlogic.gdx.Gdx;
-
-import com.badlogic.gdx.graphics.OrthographicCamera;
-
-import com.badlogic.gdx.math.Rectangle;
-import com.badlogic.gdx.math.Matrix4;
-import com.badlogic.gdx.math.Vector3;
-import com.badlogic.gdx.math.MathUtils;
-
-public class GameCamera extends OrthographicCamera
-{
- private static final float ZEROF = 0.01f;
-
- private int screenWidth;
- private int screenHeight;
- private float zoomOut;
- private float zoomIn;
- private float viewportAspect;
- private float widthFactor;
- private float heightFactor;
- private Rectangle virtual;
- private Rectangle window;
- private Matrix4 hudMatrix;
- private Matrix4 hudInvProjMatrix;
- private int hudCorrection;
- private int hudLeft;
- private int hudBottom;
-
- public GameCamera(float virtualWidth, float virtualHeight, float zoomOut, float zoomIn, int hudCorrection)
- {
- super(virtualWidth, virtualHeight);
- this.zoomOut = zoomOut;
- this.zoomIn = zoomIn;
- this.viewportAspect = (viewportWidth / viewportHeight);
- this.virtual = new Rectangle();
- this.virtual.set(0, 0, virtualWidth, virtualHeight);
- this.window = new Rectangle();
- this.hudMatrix = new Matrix4();
- this.hudInvProjMatrix = new Matrix4();
- this.hudLeft = 0;
- this.hudBottom = 0;
- this.hudCorrection = hudCorrection;
- }
-
- public void updateViewport(int screenWidth, int screenHeight)
- {
- this.screenWidth = screenWidth;
- this.screenHeight = screenHeight;
-
- float aspect = (screenWidth / (float) screenHeight);
- float diff = (viewportAspect - aspect);
-
- if (diff < -ZEROF) {
- 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));
- hudBottom = hudCorrection;
- hudLeft = (int) (hudBottom * viewportWidth / viewportHeight);
- } else if (diff > ZEROF) {
- window.width = screenWidth;
- window.height = java.lang.Math.min((screenWidth * viewportAspect / zoom), screenHeight);
- window.x = 0f;
- window.y = ((screenHeight - window.height) / 2f);
- viewportHeight = (viewportWidth * (window.height / window.width));
- hudLeft = hudCorrection;
- hudBottom = (int) (hudLeft / viewportWidth * viewportHeight);
- }
-
- Gdx.gl.glViewport((int)window.x, (int)window.y, (int)window.width, (int)window.height);
-
- this.widthFactor = (viewportWidth / screenWidth);
- this.heightFactor = (viewportHeight / screenHeight);
-
- clampPosition();
- update(true);
- hudMatrix.set(combined);
- hudMatrix.setToOrtho2D(getHudLeft(), getHudBottom(), getHudWidth(), getHudHeight());
- hudInvProjMatrix.set(hudMatrix);
- Matrix4.inv(hudInvProjMatrix.val);
- }
-
- public Matrix4 getHudMatrix()
- {
- return hudMatrix;
- }
-
- public int getScreenWidth()
- {
- return screenWidth;
- }
-
- public int getScreenHeight()
- {
- return screenHeight;
- }
-
- public int getHudLeft()
- {
- return hudLeft;
- }
-
- public int getHudBottom()
- {
- return hudBottom;
- }
-
- public int getHudWidth()
- {
- return (int) window.width - (2 * getHudLeft());
- }
-
- public int getHudHeight()
- {
- return (int) window.height - (2 * getHudBottom());
- }
-
- public void centerOnWorld()
- {
- position.set((viewportWidth / 2f), (viewportHeight / 2f), 0f);
- }
-
- public void zoom(float dz)
- {
- zoom += dz;
- clampZoom();
- updateViewport(screenWidth, screenHeight);
- }
-
- public void translate(float dx, float dy)
- {
- float deltaX = (dx * zoom * widthFactor);
- float deltaY = (dy * zoom * heightFactor);
- translate(deltaX, -deltaY, 0);
- clampPosition();
- update(true);
- }
-
- public void clampZoom()
- {
- zoom = MathUtils.clamp(zoom, zoomIn, zoomOut);
- }
-
- public void clampPosition()
- {
- float cx = (viewportWidth * zoom);
- float cy = (viewportHeight * zoom);
-
- if ((virtual.width - cx) > ZEROF) {
- cx /= 2f;
- position.x = MathUtils.clamp(position.x, cx, (virtual.width - cx));
- } else
- position.x = (virtual.width / 2f);
-
- if ((virtual.height - cy) > ZEROF) {
- cy /= 2f;
- position.y = MathUtils.clamp(position.y, cy, (virtual.height - cy));
- } else
- position.y = (virtual.height / 2f);
- }
-
- public void debug()
- {
- System.err.println(String.format(" VIEWPORT: %dx%d * %.2f -> %dx%d", (int)viewportWidth, (int)viewportHeight,
- zoom, (int)(viewportWidth * zoom), (int)(viewportHeight * zoom)));
- System.err.println(String.format(" WINDOW: %d;%d %dx%d", (int)window.x, (int)window.y, (int)window.width, (int)window.height));
- System.err.println("MATRIX:" + combined.toString());
- }
-
- public void unproject(int x, int y, Vector3 v)
- {
- unproject(v.set(x, y, 0), window.x, window.y, window.width, window.height);
- }
-
- public void unprojectHud(float x, float y, Vector3 v)
- {
- x = x - window.x;
- y = Gdx.graphics.getHeight() - y - 1;
- y = y - window.y;
- v.x = (2 * x) / window.width - 1;
- v.y = (2 * y) / window.height - 1;
- v.z = 2 * v.z - 1;
- v.prj(hudInvProjMatrix);
- }
-}
diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java
deleted file mode 100644
index d5fa401..0000000
--- a/core/src/ch/asynk/tankontank/screens/GameScreen.java
+++ /dev/null
@@ -1,217 +0,0 @@
-package ch.asynk.tankontank.screens;
-
-import com.badlogic.gdx.Gdx;
-
-import com.badlogic.gdx.Screen;
-import com.badlogic.gdx.Input;
-import com.badlogic.gdx.InputAdapter;
-import com.badlogic.gdx.InputMultiplexer;
-import com.badlogic.gdx.input.GestureDetector;
-import com.badlogic.gdx.input.GestureDetector.GestureAdapter;
-
-import com.badlogic.gdx.graphics.GL20;
-import com.badlogic.gdx.graphics.g2d.SpriteBatch;
-import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
-
-import com.badlogic.gdx.math.Vector2;
-
-import ch.asynk.tankontank.TankOnTank;
-
-import ch.asynk.tankontank.game.Ctrl;
-
-public class GameScreen implements Screen
-{
- private static boolean DEBUG = false;
-
- private static final float INPUT_DELAY = 0.1f;
- private static final float ZOOM_IN_MAX = 0.3f;
- private static final float ZOOM_OUT_MAX = 1f;
- private static final float ZOOM_GESTURE_FACTOR = .01f;
- private static final float ZOOM_SCROLL_FACTOR = .1f;
- private static final int DRAGGED_Z_INDEX = 10;
- private static final int DRAG_THRESHOLD = 6;
-
- private final GameCamera cam;
-
- private final SpriteBatch batch;
- private ShapeRenderer debugShapes = null;
-
- private final TankOnTank game;
- private Ctrl ctrl;
-
- private int dragged;
- private boolean blocked;
- private float inputDelay = 0f;
- private Vector2 dragPos = new Vector2();
-
- public GameScreen(final TankOnTank game)
- {
- DEBUG = game.config.debug;
-
- this.game = game;
- this.dragged = 0;
- this.blocked = false;
-
- this.batch = new SpriteBatch();
- this.ctrl = new Ctrl(game, game.config.battle);
- this.cam = new GameCamera(ctrl.map.getWidth(), ctrl.map.getHeight(), ZOOM_OUT_MAX, ZOOM_IN_MAX, game.hudCorrection);
-
- if (DEBUG) this.debugShapes = new ShapeRenderer();
-
- Gdx.input.setInputProcessor(getMultiplexer());
- }
-
-
- private InputMultiplexer getMultiplexer()
- {
- final InputMultiplexer multiplexer = new InputMultiplexer();
- multiplexer.addProcessor(new GestureDetector(new GestureAdapter() {
- @Override
- public boolean zoom(float initialDistance, float distance)
- {
- if (initialDistance > distance)
- cam.zoom(ZOOM_GESTURE_FACTOR);
- else
- cam.zoom(-ZOOM_GESTURE_FACTOR);
- ctrl.hud.resize(cam.getHudLeft(), cam.getHudBottom(), cam.getHudWidth(), cam.getHudHeight());
- blocked = true;
- inputDelay = INPUT_DELAY;
- return true;
- }
- }));
- multiplexer.addProcessor(new InputAdapter() {
- @Override
- public boolean touchDragged(int x, int y, int pointer)
- {
- dragged += 1;
- cam.translate((dragPos.x - x), (dragPos.y - y));
- dragPos.set(x, y);
- return true;
- }
- @Override
- public boolean touchDown(int x, int y, int pointer, int button)
- {
- if (blocked) return true;
- if (button == Input.Buttons.LEFT) {
- dragPos.set(x, y);
- cam.unproject(x, y, ctrl.mapTouch);
- cam.unprojectHud(x, y, ctrl.hudTouch);
- ctrl.touchDown();
- }
- return true;
- }
- @Override
- public boolean touchUp(int x, int y, int pointer, int button)
- {
- if (blocked) return true;
- if (dragged > DRAG_THRESHOLD) {
- dragged = 0;
- return true;
- }
- dragged = 0;
- if (button == Input.Buttons.LEFT) {
- cam.unproject(x, y, ctrl.mapTouch);
- cam.unprojectHud(x, y, ctrl.hudTouch);
- ctrl.touchUp();
- }
- return true;
- }
- @Override
- public boolean scrolled(int amount)
- {
- cam.zoom(amount * ZOOM_SCROLL_FACTOR);
- ctrl.hud.resize(cam.getHudLeft(), cam.getHudBottom(), cam.getHudWidth(), cam.getHudHeight());
- return true;
- }
- });
-
- return multiplexer;
- }
-
- @Override
- public void render(float delta)
- {
- if (inputDelay > 0f) {
- inputDelay -= delta;
- if (inputDelay <= 0f)
- blocked = false;
- }
-
- ctrl.hud.animate(delta);
- ctrl.map.animate(delta);
-
- Gdx.gl.glClearColor(0, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
-
- // cam.update();
- batch.setProjectionMatrix(cam.combined);
- batch.begin();
- ctrl.map.draw(batch);
- batch.end();
-
-
- if (DEBUG) {
- Gdx.gl.glEnable(GL20.GL_BLEND);
- debugShapes.setAutoShapeType(true);
- debugShapes.setProjectionMatrix(cam.combined);
- debugShapes.begin();
- ctrl.map.drawDebug(debugShapes);
- debugShapes.end();
- }
-
- batch.setProjectionMatrix(cam.getHudMatrix());
- batch.begin();
- ctrl.hud.draw(batch, DEBUG);
- batch.end();
-
- if (DEBUG) {
- Gdx.gl.glEnable(GL20.GL_BLEND);
- debugShapes.setAutoShapeType(true);
- debugShapes.setProjectionMatrix(cam.getHudMatrix());
- debugShapes.begin();
- ctrl.hud.drawDebug(debugShapes);
- debugShapes.end();
- }
- }
-
- @Override
- public void resize(int width, int height)
- {
- // TankOnTank.debug("GameScreen", "resize (" + width + "," + height + ")");
- cam.updateViewport(width, height);
- ctrl.hud.resize(cam.getHudLeft(), cam.getHudBottom(), cam.getHudWidth(), cam.getHudHeight());
- }
-
- @Override
- public void dispose()
- {
- // TankOnTank.debug("GameScreen", "dispose()");
- batch.dispose();
- ctrl.dispose();
- if (DEBUG) debugShapes.dispose();
- }
-
- @Override
- public void show()
- {
- // TankOnTank.debug("GameScreen", "show()");
- }
-
- @Override
- public void hide()
- {
- // TankOnTank.debug("GameScreen", "hide()");
- }
-
- @Override
- public void pause()
- {
- // TankOnTank.debug("GameScreen", "pause()");
- }
-
- @Override
- public void resume()
- {
- // TankOnTank.debug("GameScreen", "resume()");
- }
-}
diff --git a/core/src/ch/asynk/tankontank/screens/MenuCamera.java b/core/src/ch/asynk/tankontank/screens/MenuCamera.java
deleted file mode 100644
index 9e27f16..0000000
--- a/core/src/ch/asynk/tankontank/screens/MenuCamera.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package ch.asynk.tankontank.screens;
-
-import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.graphics.OrthographicCamera;
-import com.badlogic.gdx.math.Vector3;
-import com.badlogic.gdx.math.Matrix4;
-import com.badlogic.gdx.math.Rectangle;
-
-public class MenuCamera extends OrthographicCamera
-{
- private static final float ZEROF = 0.01f;
-
- private float virtualAspect;
- private final Rectangle virtual;
- private final Rectangle window;
- private int hudLeft;
- private int hudBottom;
- private int hudCorrection;
-
- private Matrix4 uiMatrix;
- private Matrix4 uiInvProjMatrix;
-
- public MenuCamera(int cx, int cy, int width, int height, int hudCorrection)
- {
- super(width, height);
- this.virtual = new Rectangle();
- this.virtual.set(cx, cy, width, height);
- this.virtualAspect = (virtual.width / virtual.height);
- this.window = new Rectangle();
- this.window.set(0, 0, 0, 0);
- this.position.set(virtual.x, virtual.y, 0f);
- this.hudLeft = 0;
- this.hudBottom = 0;
- this.hudCorrection = hudCorrection;
-
- this.uiMatrix = new Matrix4();
- this.uiInvProjMatrix = new Matrix4();
- }
-
- public void updateViewport(int screenWidth, int screenHeight)
- {
- float aspect = (screenWidth / (float) screenHeight);
- float diff = (virtualAspect - aspect);
-
- if (diff < -ZEROF) {
- viewportWidth = (virtual.height * aspect);
- viewportHeight = virtual.height;
- } else if (diff > ZEROF) {
- viewportWidth = virtual.width;
- viewportHeight = (virtual.width / aspect);
- }
-
- window.width = screenWidth;
- window.height = screenHeight;
- hudLeft = hudCorrection;
- hudBottom = (int) (hudLeft / aspect);
-
- Gdx.gl.glViewport((int)window.x, (int)window.y, (int)window.width, (int)window.height);
-
- update(true);
-
- uiMatrix.set(combined);
- uiMatrix.setToOrtho2D(getHudLeft(), getHudBottom(), getHudWidth(), getHudHeight());
- uiInvProjMatrix.set(uiMatrix);
- Matrix4.inv(uiInvProjMatrix.val);
- }
-
- public float getScreenWidth()
- {
- return window.width;
- }
-
- public float getScreenHeight()
- {
- return window.height;
- }
-
- public int getHudLeft()
- {
- return hudLeft;
- }
-
- public int getHudBottom()
- {
- return hudBottom;
- }
-
- public int getHudWidth()
- {
- return (int) window.width - (2 * getHudLeft());
- }
-
- public int getHudHeight()
- {
- return (int) window.height - (2 * getHudBottom());
- }
-
- public void uiUnproject(float x, float y, Vector3 v)
- {
- x = x - window.x;
- y = Gdx.graphics.getHeight() - y - 1;
- y = y - window.y;
- v.x = (2 * x) / window.width - 1;
- v.y = (2 * y) / window.height - 1;
- v.z = 2 * v.z - 1;
- v.prj(uiInvProjMatrix);
- }
-
- public Matrix4 uiCombined()
- {
- return uiMatrix;
- }
-}
diff --git a/core/src/ch/asynk/tankontank/screens/MenuScreen.java b/core/src/ch/asynk/tankontank/screens/MenuScreen.java
deleted file mode 100644
index 9486413..0000000
--- a/core/src/ch/asynk/tankontank/screens/MenuScreen.java
+++ /dev/null
@@ -1,264 +0,0 @@
-package ch.asynk.tankontank.screens;
-
-import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.Screen;
-import com.badlogic.gdx.InputAdapter;
-import com.badlogic.gdx.graphics.GL20;
-import com.badlogic.gdx.graphics.Texture;
-import com.badlogic.gdx.graphics.g2d.SpriteBatch;
-import com.badlogic.gdx.graphics.g2d.TextureAtlas;
-import com.badlogic.gdx.graphics.g2d.TextureRegion;
-import com.badlogic.gdx.graphics.g2d.Sprite;
-import com.badlogic.gdx.math.Vector3;
-import com.badlogic.gdx.math.Interpolation;
-
-import ch.asynk.tankontank.TankOnTank;
-import ch.asynk.tankontank.ui.Position;
-import ch.asynk.tankontank.menu.MainMenu;
-import ch.asynk.tankontank.menu.OptionsMenu;
-import ch.asynk.tankontank.menu.ScenariosMenu;
-import ch.asynk.tankontank.menu.TutorialsMenu;
-
-public class MenuScreen implements Screen
-{
- private final TankOnTank game;
-
- private final int OFFSET = 20;
- private final int V_WIDTH = 1600;
- private final int V_HEIGHT = 1125;
- private final int V_CENTER_X = 1000;
- private final int V_CENTER_Y = 890;
-
- private float percent;
- private float delay = 0.0f;
- private float dx;
- private float dy;
- private int[] xPath = { 369, 558, 747, 936, 1125, 1030, 936, 1125, 1314, 1408, 1597};
- private int[] yPath = { 565, 565, 565, 565, 565, 729, 892, 892, 892, 1056, 1056};
- private int n = xPath.length;
-
- private boolean ready;
- private boolean gameAssetsLoading;
- private Texture bg;
-
- private Sprite unit;
- private Sprite move;
- private Sprite from;
- private Sprite to;
- private Sprite geFlag;
- private Sprite usFlag;
- private Sprite lnl;
- private Sprite logo;
-
- private MainMenu mainMenu;
- private OptionsMenu optionsMenu;
- private ScenariosMenu scenariosMenu;
- private TutorialsMenu tutorialsMenu;
-
- private final MenuCamera camera;
- private final SpriteBatch batch;
- private Vector3 touch = new Vector3();
-
- public MenuScreen(final TankOnTank game)
- {
- this.game = game;
- this.batch = new SpriteBatch();
-
- float width = Gdx.graphics.getWidth();
- float height = Gdx.graphics.getHeight();
-
- this.camera = new MenuCamera(V_CENTER_X, V_CENTER_Y, V_WIDTH, V_HEIGHT, game.hudCorrection);
-
- this.gameAssetsLoading = false;
-
- this.bg = game.manager.get("data/map_a.png", Texture.class);
-
- this.unit = new Sprite(game.menuAtlas.findRegion("unit"));
- this.move = new Sprite(game.menuAtlas.findRegion("move"));
- this.from = new Sprite(game.menuAtlas.findRegion("from"));
- this.to = new Sprite(game.menuAtlas.findRegion("to"));
- this.usFlag = new Sprite(game.menuAtlas.findRegion("us-flag"));
- this.geFlag = new Sprite(game.menuAtlas.findRegion("ge-flag"));
- this.lnl = new Sprite(game.menuAtlas.findRegion("lnl"));
- this.logo = new Sprite(game.menuAtlas.findRegion("logo"));
-
- this.mainMenu = new MainMenu(game.fontB, game.uiAtlas);
- this.optionsMenu = new OptionsMenu(game, game.fontB, game.uiAtlas);
- this.scenariosMenu = new ScenariosMenu(game, game.fontB, game.uiAtlas);
- this.tutorialsMenu = new TutorialsMenu(game, game.fontB, game.uiAtlas);
-
- this.game.config.battle = null;
-
- Gdx.input.setInputProcessor(new InputAdapter() {
- @Override
- public boolean touchDown(int x, int y, int pointer, int button)
- {
- camera.uiUnproject(x, y, touch);
- return hit(touch.x, touch.y);
- }
- });
- }
-
- private boolean hit(float x, float y)
- {
- if (mainMenu.hit(x, y)) {
- mainMenu.visible = false;
- showNextMenu();
- return true;
- } else if (optionsMenu.hit(x, y)) {
- mainMenu.visible = true;
- optionsMenu.visible = false;
- return true;
- } else if (scenariosMenu.hit(x, y)) {
- mainMenu.visible = true;
- scenariosMenu.visible = false;
- if (scenariosMenu.launch)
- startLoading();
- return true;
- } else if (tutorialsMenu.hit(x, y)) {
- mainMenu.visible = true;
- tutorialsMenu.visible = false;
- return true;
- }
-
- return false;
- }
-
- private void showNextMenu()
- {
- MainMenu.Items item = mainMenu.getMenu();
-
- if (item == MainMenu.Items.OPTIONS)
- optionsMenu.visible = true;
- else if (item == MainMenu.Items.SCENARIOS)
- scenariosMenu.visible = true;
- else if (item == MainMenu.Items.TUTORIALS)
- tutorialsMenu.visible = true;
- }
-
- private void startLoading()
- {
- mainMenu.visible = false;
- game.loadGameAssets();
- gameAssetsLoading = true;
- }
-
- private void gameAssetsLoadingCompleted()
- {
- TankOnTank.debug("LoadScreen", "assets ready : " + (Gdx.app.getJavaHeap()/1024.0f) + "KB");
- game.switchToGame();
- dispose();
- }
-
- @Override
- public void render(float delta)
- {
- float x = xPath[0];
- float y = yPath[0];
- if (gameAssetsLoading) {
- if (game.manager.update()) {
- delay += delta;
- if (delay >= 0.6f)
- gameAssetsLoadingCompleted();
- }
-
- percent = Interpolation.linear.apply(percent, game.manager.getProgress(), 0.1f);
- int idx = (int) (percent * 10);
- float fraction = ((percent * 100 ) % 10 / 10);
- x = (xPath[idx] + ((xPath[idx + 1] - xPath[idx]) * fraction));
- y = (yPath[idx] + ((yPath[idx + 1] - yPath[idx]) * fraction));
- }
-
- Gdx.gl.glClearColor(0, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
-
- batch.setProjectionMatrix(camera.combined);
- batch.begin();
- batch.draw(bg, 0, 0);
- from.draw(batch);
- to.draw(batch);
- usFlag.draw(batch);
- geFlag.draw(batch);
- for (int i = 1; i < (n - 1); i++)
- drawCentered(batch, move, xPath[i], yPath[i]);
- drawCentered(batch, unit, (int) (x + dx), (int) (y + dy));
- batch.end();
-
- batch.setProjectionMatrix(camera.uiCombined());
- batch.begin();
- batch.draw(logo, OFFSET, (camera.getScreenHeight() - logo.getRegionHeight() - OFFSET));
- batch.draw(lnl, (camera.getScreenWidth() - lnl.getRegionWidth() - (2 * OFFSET)), (2 * OFFSET));
- mainMenu.draw(batch);
- optionsMenu.draw(batch);
- scenariosMenu.draw(batch);
- tutorialsMenu.draw(batch);
- batch.end();
- }
-
- private void drawCentered(SpriteBatch batch, TextureRegion region, int x, int y)
- {
- batch.draw(region, (x - (region.getRegionWidth() / 2f)), (y - (region.getRegionHeight() / 2f)));
- }
-
- private void setCenteredPosition(Sprite sprite, int x, int y)
- {
- sprite.setPosition((x - (sprite.getWidth() / 2f)), (y - (sprite.getHeight() / 2f)));
- }
-
- private void update(int width, int height)
- {
- camera.updateViewport(width, height);
- Position.update(camera.getHudLeft(), camera.getHudBottom(), camera.getHudWidth(), camera.getHudHeight());
-
- setCenteredPosition(from, xPath[0], yPath[0]);
- setCenteredPosition(to, xPath[n - 1], yPath[n - 1]);
- setCenteredPosition(usFlag, xPath[0], yPath[0]);
- setCenteredPosition(geFlag, xPath[n - 1], yPath[n - 1]);
-
- mainMenu.setPosition();
- optionsMenu.setPosition();
- scenariosMenu.setPosition();
- tutorialsMenu.setPosition();
- }
-
- @Override
- public void resize(int width, int height)
- {
- update(width, height);
- }
-
- @Override
- public void dispose()
- {
- mainMenu.dispose();
- optionsMenu.dispose();
- scenariosMenu.dispose();
- tutorialsMenu.dispose();
- }
-
- @Override
- public void show()
- {
- int width = (int) Gdx.graphics.getWidth();
- int height = (int) Gdx.graphics.getHeight();
- update(width, height);
- }
-
- @Override
- public void hide()
- {
- // TankOnTank.debug("MenuScreen", "hide()");
- }
-
- @Override
- public void pause()
- {
- // TankOnTank.debug("MenuScreen", "pause()");
- }
-
- @Override
- public void resume()
- {
- // TankOnTank.debug("MenuScreen", "resume()");
- }
-}