summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-10 17:35:28 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-10 17:35:28 +0100
commit8ebce86d43d4fd9585153dfa69b0def27e833da6 (patch)
treed04311d3f7deff1d87d9acd7abb7b5fdc8c563fe
parentdde983d7fabe796d897f2845a2ec6a1fc6e84e1e (diff)
downloadRustAndDust-8ebce86d43d4fd9585153dfa69b0def27e833da6.zip
RustAndDust-8ebce86d43d4fd9585153dfa69b0def27e833da6.tar.gz
Position: add up(), down(), isLeft(), isCenter(), isRight()
-rw-r--r--core/src/ch/asynk/tankontank/game/hud/Position.java94
1 files changed, 94 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
index 05159ae..0556aba 100644
--- a/core/src/ch/asynk/tankontank/game/hud/Position.java
+++ b/core/src/ch/asynk/tankontank/game/hud/Position.java
@@ -15,6 +15,100 @@ public enum Position
BOTTOM_RIGHT,
BOTTOM_CENTER;
+ public Position down()
+ {
+ Position p = BOTTOM_LEFT;
+ switch(this) {
+ case TOP_LEFT:
+ case MIDDLE_LEFT:
+ case BOTTOM_LEFT:
+ p = BOTTOM_LEFT;
+ break;
+ case TOP_CENTER:
+ case MIDDLE_CENTER:
+ case BOTTOM_CENTER:
+ p = BOTTOM_CENTER;
+ break;
+ case TOP_RIGHT:
+ case MIDDLE_RIGHT:
+ case BOTTOM_RIGHT:
+ p = BOTTOM_RIGHT;
+ break;
+ }
+ return p;
+ }
+
+ public Position up()
+ {
+ Position p = TOP_LEFT;
+ switch(this) {
+ case TOP_LEFT:
+ case MIDDLE_LEFT:
+ case BOTTOM_LEFT:
+ p = TOP_LEFT;
+ break;
+ case TOP_CENTER:
+ case MIDDLE_CENTER:
+ case BOTTOM_CENTER:
+ p = TOP_CENTER;
+ break;
+ case TOP_RIGHT:
+ case MIDDLE_RIGHT:
+ case BOTTOM_RIGHT:
+ p = TOP_RIGHT;
+ break;
+ }
+ return p;
+ }
+
+ public boolean isLeft()
+ {
+ boolean r = false;
+ switch(this) {
+ case TOP_LEFT:
+ case MIDDLE_LEFT:
+ case BOTTOM_LEFT:
+ r = true;
+ break;
+ default:
+ r = false;
+ break;
+ }
+ return r;
+ }
+
+ public boolean isRight()
+ {
+ boolean r = false;
+ switch(this) {
+ case TOP_RIGHT:
+ case MIDDLE_RIGHT:
+ case BOTTOM_RIGHT:
+ r = true;
+ break;
+ default:
+ r = false;
+ break;
+ }
+ return r;
+ }
+
+ public boolean isCenter()
+ {
+ boolean r = false;
+ switch(this) {
+ case TOP_CENTER:
+ case MIDDLE_CENTER:
+ case BOTTOM_CENTER:
+ r = true;
+ break;
+ default:
+ r = false;
+ break;
+ }
+ return r;
+ }
+
public float getX(float width)
{
float x;