/** * Calcula la distancia horizontal entre esta entidad y otra. * * @param another a {@link GameEntity} * @return a float. */ public float getXDistance(GameEntity another) { float entityX = this.getX(); float playerX = another.getX(); float xDistance = playerX - entityX; return xDistance; }
/** * Calcula la distancia vertical entre esta entidad y otra. * * @param another a {@link GameEntity} * @return a float. */ public float getYDistance(GameEntity another) { float entityY = this.getY(); float playerY = another.getY(); float yDistance = playerY - entityY; return yDistance; }