Class Utilities

java.lang.Object
com.mygdx.utils.Utilities

public final class Utilities
extends java.lang.Object
Helper functions
  • Constructor Summary

    Constructors
    Constructor Description
    Utilities()  
  • Method Summary

    Modifier and Type Method Description
    static float angleBetween​(com.badlogic.gdx.math.Vector2 v, com.badlogic.gdx.math.Vector2 w)  
    static com.badlogic.gdx.math.Vector2 angleToVector​(com.badlogic.gdx.math.Vector2 out, float angle)  
    static boolean checkProximity​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, float radius)
    checks the proximity of point a to point b
    static <T> boolean contains​(java.util.ArrayList<T> array, T a)
    does array contain a
    static int distanceToTiles​(float dist)  
    static com.badlogic.gdx.math.Vector2 distanceToTiles​(com.badlogic.gdx.math.Vector2 dist)  
    static com.badlogic.gdx.math.Vector2 floor​(com.badlogic.gdx.math.Vector2 a)
    floors the vector
    static void print​(java.lang.String v)
    helper for System.out.println
    static void print​(java.lang.String v, java.lang.String eol)
    helper for System.out.print
    static <T> T randomChoice​(java.util.ArrayList<T> list, java.lang.Integer choice)
    Chooses a random element
    static com.badlogic.gdx.math.Vector2 randomPos​(float min, float max)
    Random Vec2 in range
    static com.badlogic.gdx.math.Vector2 round​(com.badlogic.gdx.math.Vector2 x)  
    static float scale​(float x, float min0, float max0, float min1, float max1)  
    static float scale​(float x, com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)  
    static float tilesToDistance​(float tiles)  
    static com.badlogic.gdx.math.Vector2 tilesToDistance​(com.badlogic.gdx.math.Vector2 tiles)  
    static float vectorToAngle​(com.badlogic.gdx.math.Vector2 v)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Utilities

      public Utilities()
  • Method Details

    • vectorToAngle

      public static float vectorToAngle​(com.badlogic.gdx.math.Vector2 v)
    • angleToVector

      public static com.badlogic.gdx.math.Vector2 angleToVector​(com.badlogic.gdx.math.Vector2 out, float angle)
    • tilesToDistance

      public static float tilesToDistance​(float tiles)
    • tilesToDistance

      public static com.badlogic.gdx.math.Vector2 tilesToDistance​(com.badlogic.gdx.math.Vector2 tiles)
    • distanceToTiles

      public static int distanceToTiles​(float dist)
    • distanceToTiles

      public static com.badlogic.gdx.math.Vector2 distanceToTiles​(com.badlogic.gdx.math.Vector2 dist)
    • checkProximity

      public static boolean checkProximity​(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, float radius)
      checks the proximity of point a to point b
      Parameters:
      a - first point
      b - second point
      radius - min dist to be considered close
      Returns:
      |dist(a, b)| ≶ radius
    • angleBetween

      public static float angleBetween​(com.badlogic.gdx.math.Vector2 v, com.badlogic.gdx.math.Vector2 w)
    • scale

      public static float scale​(float x, float min0, float max0, float min1, float max1)
    • scale

      public static float scale​(float x, com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)
    • round

      public static com.badlogic.gdx.math.Vector2 round​(com.badlogic.gdx.math.Vector2 x)
      Parameters:
      x - the vector to round
      Returns:
      x modified for chaining
    • randomPos

      public static com.badlogic.gdx.math.Vector2 randomPos​(float min, float max)
      Random Vec2 in range
      Parameters:
      min - inclusive
      max - exclusive
      Returns:
      rand Vector2
    • randomChoice

      public static <T> T randomChoice​(java.util.ArrayList<T> list, java.lang.Integer choice)
      Chooses a random element
      Type Parameters:
      T - type of element to return
      Parameters:
      list - source
      choice - the index of the chosen element
      Returns:
      the random element
    • floor

      public static com.badlogic.gdx.math.Vector2 floor​(com.badlogic.gdx.math.Vector2 a)
      floors the vector
      Parameters:
      a - given vector
      Returns:
      new vector floored
    • print

      public static void print​(java.lang.String v, java.lang.String eol)
      helper for System.out.print
      Parameters:
      v - string
      eol - eol msg
    • print

      public static void print​(java.lang.String v)
      helper for System.out.println
      Parameters:
      v - string
    • contains

      public static <T> boolean contains​(java.util.ArrayList<T> array, T a)
      does array contain a
      Type Parameters:
      T - type of element looking for
      Parameters:
      array - source
      a - desired
      Returns:
      true if contained otherwise false