package com.dunerealms.gui; /** Turns an offset into words a player can follow. North is -Z, east is +X. */ final class Bearing { private static final String[] POINTS={"north","north-east","east","south-east","south","south-west","west","north-west"}; private Bearing(){} static String direction(double dx,double dz){double degrees=Math.toDegrees(Math.atan2(dx,-dz));if(degrees<0)degrees+=360;return POINTS[(int)Math.round(degrees/45.0)%8];} static String describe(double dx,double dz){int blocks=(int)Math.round(Math.hypot(dx,dz));return blocks<6?"right beside you":blocks+" blocks "+direction(dx,dz);} }