summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank/game
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-01 11:33:45 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-01 11:33:45 +0100
commita9f54e6e2d503f5f07c427a9fb928fca61f5d194 (patch)
tree32c821473c953a8e78413a3b7b0fc99c0c6581cf /core/src/ch/asynk/tankontank/game
parent6f9f58ddce4f32dd8769370b1cde0e9d4376921d (diff)
downloadRustAndDust-a9f54e6e2d503f5f07c427a9fb928fca61f5d194.zip
RustAndDust-a9f54e6e2d503f5f07c427a9fb928fca61f5d194.tar.gz
add game/hud/Position
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Position.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/hud/Position.java b/core/src/ch/asynk/tankontank/game/hud/Position.java
new file mode 100644
index 0000000..219d4ed
--- /dev/null
+++ b/core/src/ch/asynk/tankontank/game/hud/Position.java
@@ -0,0 +1,69 @@
+package ch.asynk.tankontank.game.hud;
+
+import com.badlogic.gdx.Gdx;
+
+public enum Position
+{
+ TOP_LEFT,
+ TOP_RIGHT,
+ TOP_CENTER,
+ MIDDLE_LEFT,
+ MIDDLE_RIGHT,
+ MIDDLE_CENTER,
+ BOTTOM_LEFT,
+ BOTTOM_RIGHT,
+ BOTTOM_CENTER;
+ private float offset = 40f;
+
+ public float getX(float width)
+ {
+ float x;
+ switch(this) {
+ case TOP_LEFT:
+ case MIDDLE_LEFT:
+ case BOTTOM_LEFT:
+ x = offset;
+ break;
+ case TOP_CENTER:
+ case MIDDLE_CENTER:
+ case BOTTOM_CENTER:
+ x = ((Gdx.graphics.getWidth() - width) / 2);
+ break;
+ case TOP_RIGHT:
+ case MIDDLE_RIGHT:
+ case BOTTOM_RIGHT:
+ x = (Gdx.graphics.getWidth() - width - offset);
+ break;
+ default:
+ x = ((Gdx.graphics.getWidth() - width) / 2);
+ break;
+ }
+ return x;
+ }
+
+ public float getY(float height)
+ {
+ float y;
+ switch(this) {
+ case TOP_LEFT:
+ case TOP_CENTER:
+ case TOP_RIGHT:
+ y = (Gdx.graphics.getHeight() - height - offset);
+ break;
+ case MIDDLE_LEFT:
+ case MIDDLE_CENTER:
+ case MIDDLE_RIGHT:
+ y = ((Gdx.graphics.getHeight() - height) / 2);
+ break;
+ case BOTTOM_LEFT:
+ case BOTTOM_CENTER:
+ case BOTTOM_RIGHT:
+ y = offset;
+ break;
+ default:
+ y = ((Gdx.graphics.getHeight() - height) / 2);
+ break;
+ }
+ return y;
+ }
+}