summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/screens
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-13 23:52:37 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-13 23:52:37 +0200
commit482f92f1347774c8e411d2916bd205f80f8e548f (patch)
tree08f88dd4907686e3572027025b8b44511b162e70 /core/src/ch/asynk/tankontank/screens
parentbd34492244c2d177fd8f080e1db78816a828441e (diff)
downloadRustAndDust-482f92f1347774c8e411d2916bd205f80f8e548f.zip
RustAndDust-482f92f1347774c8e411d2916bd205f80f8e548f.tar.gz
use HexMap and show touched cell
Diffstat (limited to 'core/src/ch/asynk/tankontank/screens')
-rw-r--r--core/src/ch/asynk/tankontank/screens/GameScreen.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/src/ch/asynk/tankontank/screens/GameScreen.java b/core/src/ch/asynk/tankontank/screens/GameScreen.java
index 26db2d6..c416043 100644
--- a/core/src/ch/asynk/tankontank/screens/GameScreen.java
+++ b/core/src/ch/asynk/tankontank/screens/GameScreen.java
@@ -14,15 +14,16 @@ import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.Stage;
-import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.math.Vector2;
+import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import ch.asynk.tankontank.TankOnTank;
+import ch.asynk.tankontank.actors.HexMap;
public class GameScreen extends AbstractScreen
{
@@ -33,25 +34,29 @@ public class GameScreen extends AbstractScreen
private float maxZoomOut;
final OrthographicCamera cam;
- private Image map;
+ private HexMap map;
private Label fps;
private Label camInfo;
+ private Label cellInfo;
private Stage hud;
private Stage gameStage;
private Vector2 screenToViewport = new Vector2(); // ratio
+ private Vector3 touchPos = new Vector3(); // world coordinates
private Vector2 dragPos = new Vector2(); // screen coordinates
public GameScreen(final TankOnTank game)
{
super(game);
- map = new Image(game.manager.get("images/map_a.png", Texture.class));
+ map = new HexMap(10, 8, game.manager.get("images/map_a.png", Texture.class));
fps = new Label("FPS: 0", game.skin);
camInfo = new Label("", game.skin);
+ cellInfo = new Label("", game.skin);
fps.setPosition( 10, Gdx.graphics.getHeight() - 40);
camInfo.setPosition( 10, Gdx.graphics.getHeight() - 50);
+ cellInfo.setPosition( 10, Gdx.graphics.getHeight() - 70);
cam = new OrthographicCamera();
cam.setToOrtho(false);
@@ -63,6 +68,7 @@ public class GameScreen extends AbstractScreen
hud = new Stage(new ScreenViewport());
hud.addActor(fps);
hud.addActor(camInfo);
+ hud.addActor(cellInfo);
Gdx.input.setInputProcessor(getMultiplexer());
@@ -95,6 +101,8 @@ public class GameScreen extends AbstractScreen
{
if (button == Input.Buttons.LEFT) {
dragPos.set(x, y);
+ cam.unproject(touchPos.set(x, y, 0));
+ map.selectCell(touchPos.x, touchPos.y);
}
return true;
}
@@ -127,8 +135,9 @@ public class GameScreen extends AbstractScreen
cam.update();
- fps.setText("FPS: " + Gdx.graphics.getFramesPerSecond() + " zoom: " + String.format("%.2f", cam.zoom));
+ fps.setText("FPS: " + Gdx.graphics.getFramesPerSecond());
camInfo.setText("Camera: " + (int) cam.position.y + " ; " + (int) cam.position.y + " x " + String.format("%.2f", cam.zoom));
+ cellInfo.setText("Cell: " + map.cell.x + " ; " + map.cell.y);
gameStage.act(delta);
gameStage.draw();