diff options
Diffstat (limited to 'core/src/ch/asynk/gdx')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/Piece.java | 8 | ||||
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/boards/Board.java | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/Piece.java b/core/src/ch/asynk/gdx/boardgame/Piece.java index ee0353a..6d2bf52 100644 --- a/core/src/ch/asynk/gdx/boardgame/Piece.java +++ b/core/src/ch/asynk/gdx/boardgame/Piece.java @@ -10,6 +10,7 @@ import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.MathUtils; +import ch.asynk.gdx.boardgame.boards.Board; import ch.asynk.gdx.boardgame.Drawable; import ch.asynk.gdx.boardgame.Orientation; import ch.asynk.gdx.boardgame.Positionable; @@ -44,6 +45,13 @@ public class Piece implements Drawable, Positionable, Rotable, Scalable setRotation(r); } + public void dropOnBoard(Board board, Vector2 v) + { + board.toBoard(getCX(), getCY(), v); + board.centerOf((int)v.x, (int)v.y, v); + centerOn(v.x, v.y); + } + public boolean isOn(Tile tile) { return ( diff --git a/core/src/ch/asynk/gdx/boardgame/boards/Board.java b/core/src/ch/asynk/gdx/boardgame/boards/Board.java index 6cabcee..7c72c25 100644 --- a/core/src/ch/asynk/gdx/boardgame/boards/Board.java +++ b/core/src/ch/asynk/gdx/boardgame/boards/Board.java @@ -2,6 +2,7 @@ package ch.asynk.gdx.boardgame.boards; import com.badlogic.gdx.math.Vector2; +import ch.asynk.gdx.boardgame.Piece; import ch.asynk.gdx.boardgame.Tile; import ch.asynk.gdx.boardgame.tilestorages.TileStorage.TileProvider; import ch.asynk.gdx.boardgame.tilestorages.TileStorage.TileKeyGenerator; @@ -25,4 +26,11 @@ public interface Board extends TileKeyGenerator TCHEBYCHEV } public float distance(int x0, int y0, int x1, int y1, Geometry geometry); + + default public void dropInPlace(Piece piece, Vector2 v) + { + toBoard(piece.getCX(), piece.getCY(), v); + centerOf((int)v.x, (int)v.y, v); + piece.centerOn(v.x, v.y); + } } |