From 661b01f18465a1d23953e1bd87ef3d8579637092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 17 Oct 2018 16:01:16 +0200 Subject: Orientation : add fromTiles(Tile, Tile) --- core/src/ch/asynk/gdx/boardgame/Orientation.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/ch/asynk/gdx/boardgame/Orientation.java b/core/src/ch/asynk/gdx/boardgame/Orientation.java index 835afe4..677c979 100644 --- a/core/src/ch/asynk/gdx/boardgame/Orientation.java +++ b/core/src/ch/asynk/gdx/boardgame/Orientation.java @@ -1,5 +1,7 @@ package ch.asynk.gdx.boardgame; +import com.badlogic.gdx.math.MathUtils; + public enum Orientation { ALL(255, 0), @@ -87,4 +89,9 @@ public enum Orientation else return KEEP; } + + public static Orientation fromTiles(Tile from, Tile to) + { + return fromR(MathUtils.atan2((to.y - from.y), (to.x - from.x)) * MathUtils.radiansToDegrees); + } } -- cgit v1.1-2-g2b99