Package com.mygdx.utils
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 floatangleBetween(com.badlogic.gdx.math.Vector2 v, com.badlogic.gdx.math.Vector2 w)static com.badlogic.gdx.math.Vector2angleToVector(com.badlogic.gdx.math.Vector2 out, float angle)static booleancheckProximity(com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b, float radius)checks the proximity of point a to point bstatic <T> booleancontains(java.util.ArrayList<T> array, T a)does array contain astatic intdistanceToTiles(float dist)static com.badlogic.gdx.math.Vector2distanceToTiles(com.badlogic.gdx.math.Vector2 dist)static com.badlogic.gdx.math.Vector2floor(com.badlogic.gdx.math.Vector2 a)floors the vectorstatic voidprint(java.lang.String v)helper for System.out.printlnstatic voidprint(java.lang.String v, java.lang.String eol)helper for System.out.printstatic <T> TrandomChoice(java.util.ArrayList<T> list, java.lang.Integer choice)Chooses a random elementstatic com.badlogic.gdx.math.Vector2randomPos(float min, float max)Random Vec2 in rangestatic com.badlogic.gdx.math.Vector2round(com.badlogic.gdx.math.Vector2 x)static floatscale(float x, float min0, float max0, float min1, float max1)static floatscale(float x, com.badlogic.gdx.math.Vector2 a, com.badlogic.gdx.math.Vector2 b)static floattilesToDistance(float tiles)static com.badlogic.gdx.math.Vector2tilesToDistance(com.badlogic.gdx.math.Vector2 tiles)static floatvectorToAngle(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 pointb- second pointradius- 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- inclusivemax- 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- sourcechoice- 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- stringeol- 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- sourcea- desired- Returns:
- true if contained otherwise false
-