diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-11 10:38:08 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2020-07-11 10:38:08 +0200 |
commit | 0fcdc724db59ea3c1c3357d320ce745a2ca44f2f (patch) | |
tree | 0a23e89dc5ad8a7d8a7c9936c13c79d44be075b0 /core/src/ch/asynk/gdx/boardgame | |
parent | 5b808951945b900819669a989cced457fb0068ce (diff) | |
download | gdx-boardgame-0fcdc724db59ea3c1c3357d320ce745a2ca44f2f.zip gdx-boardgame-0fcdc724db59ea3c1c3357d320ce745a2ca44f2f.tar.gz |
Orientation : simplify fromR()
Diffstat (limited to 'core/src/ch/asynk/gdx/boardgame')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/Orientation.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/Orientation.java b/core/src/ch/asynk/gdx/boardgame/Orientation.java index 2d24603..d2aea8b 100644 --- a/core/src/ch/asynk/gdx/boardgame/Orientation.java +++ b/core/src/ch/asynk/gdx/boardgame/Orientation.java @@ -88,16 +88,16 @@ public enum Orientation public static Orientation fromR(float r) { if (r < 0) r += 360f; - if ( E.r != -1 && (r > ( E.r - delta)) && (r < ( E.r + delta))) return E; - else if (NE.r != -1 && (r > (NE.r - delta)) && (r < (NE.r + delta))) return NE; - else if ( N.r != -1 && (r > ( N.r - delta)) && (r < ( N.r + delta))) return N; - else if (NW.r != -1 && (r > (NW.r - delta)) && (r < (NW.r + delta))) return NW; - else if ( W.r != -1 && (r > ( W.r - delta)) && (r < ( W.r + delta))) return W; - else if (SW.r != -1 && (r > (SW.r - delta)) && (r < (SW.r + delta))) return SW; - else if ( S.r != -1 && (r > ( S.r - delta)) && (r < ( S.r + delta))) return S; - else if (SE.r != -1 && (r > (SE.r - delta)) && (r < (SE.r + delta))) return SE; - else return KEEP; - + int v = ((int)(r + 2) / 10 * 10); + if (v == E.r) return E; + else if (v == NE.r) return NE; + else if (v == N.r) return N; + else if (v == NW.r) return NW; + else if (v == W.r) return W; + else if (v == SW.r) return SW; + else if (v == S.r) return S; + else if (v == SE.r) return SE; + return KEEP; } public static Orientation fromTiles(Tile from, Tile to) |