@Override public void onMoved(MovedEvent event) { Point2D point = parent.getBoardSvg().calculatePosition(robber.getLocation()); Point2D headLocation = getHeadLocation(point); Point2D bodyLocation = getBodyLocation(point); head.setX(headLocation.getX()); head.setY(headLocation.getY()); body.setX(bodyLocation.getX()); body.setY(bodyLocation.getY()); }
public RobberSvg(GameBoardSvg parent, Robber robber) { super(robber); this.parent = parent; int headRadius = (int) (parent.getBoardSvg().getHexagonWidth() / 8); int bodyRadius = (int) (parent.getBoardSvg().getHexagonWidth() / 6); Point2D point = parent.getBoardSvg().calculatePosition(robber.getLocation()); Point2D headLocation = getHeadLocation(point); Point2D bodyLocation = getBodyLocation(point); head = new Circle(headLocation.getX(), headLocation.getY(), headRadius); head.setFillColor("Black"); head.setStrokeColor("White"); body = new Circle(bodyLocation.getX(), bodyLocation.getY(), bodyRadius); body.setFillColor("Black"); body.setStrokeColor("White"); group = new Group(); group.add(body); group.add(head); robber.addMoveEventHandler(this); }
private Point2D getBodyLocation(Point2D point) { int hBodyOffset = (int) (parent.getBoardSvg().getHexagonWidth() / 5); int vBodyOffset = (int) (parent.getBoardSvg().getHexagonWidth() / 5) * 2; return new Point2D(point.getX() + hBodyOffset, point.getY() + vBodyOffset); }
private Point2D getHeadLocation(Point2D point) { int hHeadOffset = (int) (parent.getBoardSvg().getHexagonWidth() / 5); int vHeadOffset = (int) (parent.getBoardSvg().getHexagonWidth() / 5); return new Point2D(point.getX() + hHeadOffset, point.getY() + vHeadOffset); }