Enum CollisionPositions
java.lang.Object
java.lang.Enum<CollisionPositions>
fr.r1r0r0.deltaengine.model.elements.CollisionPositions
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<CollisionPositions>,java.lang.constant.Constable
public enum CollisionPositions extends java.lang.Enum<CollisionPositions>
A set of point that are used to calculate collision points and hit-box of entity
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
java.lang.Enum.EnumDesc<E extends java.lang.Enum<E>> -
Enum Constant Summary
Enum Constants Enum Constant Description CENTER_BOTCENTER_CENTERCENTER_TOPLEFT_BOTLEFT_CENTERLEFT_TOPRIGHT_BOTRIGHT_CENTERRIGHT_TOP -
Field Summary
Fields Modifier and Type Field Description static CollisionPositions[]BASIC_COLLISION_POSITIONprivate doubleratioXprivate doubleratioY -
Constructor Summary
Constructors Modifier Constructor Description privateCollisionPositions(double ratioX, double ratioY)Constructor -
Method Summary
Modifier and Type Method Description Coordinates<java.lang.Double>calcPosition(Coordinates<java.lang.Double> topLeft, Dimension dimension)Return the position calculate in a rectangleprivate static Coordinates<java.lang.Double>calcTopLetHitBox(Coordinates<java.lang.Double> topLeftDimension, Dimension dimension, Dimension hitBox)Calc and return the top left point of the hit-box matching to an entity with describe by : a top left position of the dimension, a dimension size and a hit-box sizestatic Coordinates<java.lang.Double>calcTopLetHitBox(Entity entity)Calc and return the top left point of the hit-box of the entitystatic booleanisInHitBox(Coordinates<java.lang.Double> topLeft, Dimension dimension, Coordinates<java.lang.Double> collisionPoint)Return if the collisionPoint given is contain in the hit-box described by the topLeft point and the dimension.static booleansimplyCollide(Entity entity1, Entity entity2)Return if there is a collision between the 2 entity The type of calculation used to do that is simplest than the usual way to do thatstatic CollisionPositionsvalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static CollisionPositions[]values()Returns an array containing the constants of this enum type, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
-
Enum Constant Details
-
LEFT_TOP
-
RIGHT_TOP
-
LEFT_BOT
-
RIGHT_BOT
-
CENTER_CENTER
-
CENTER_TOP
-
CENTER_BOT
-
LEFT_CENTER
-
RIGHT_CENTER
-
-
Field Details
-
BASIC_COLLISION_POSITION
-
ratioX
private final double ratioX -
ratioY
private final double ratioY
-
-
Constructor Details
-
CollisionPositions
private CollisionPositions(double ratioX, double ratioY)Constructor- Parameters:
ratioX- a ratio of dimension XratioY- a ratio of dimension Y
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
calcPosition
public Coordinates<java.lang.Double> calcPosition(Coordinates<java.lang.Double> topLeft, Dimension dimension)Return the position calculate in a rectangle- Parameters:
topLeft- the top-left pointdimension- the dimension of the rectangle- Returns:
- the position calculate in a rectangle
-
calcTopLetHitBox
Calc and return the top left point of the hit-box of the entity- Parameters:
entity- an entity- Returns:
- the top left point of the hit-box of the entity
-
calcTopLetHitBox
private static Coordinates<java.lang.Double> calcTopLetHitBox(Coordinates<java.lang.Double> topLeftDimension, Dimension dimension, Dimension hitBox)Calc and return the top left point of the hit-box matching to an entity with describe by : a top left position of the dimension, a dimension size and a hit-box size- Parameters:
topLeftDimension- a top left position of the dimensiondimension- a dimensionhitBox- a hit-box- Returns:
- the top left point of the hit-box matching to an entity with describe by : a top left position of the dimension, a dimension size and a hit-box size
-
isInHitBox
public static boolean isInHitBox(Coordinates<java.lang.Double> topLeft, Dimension dimension, Coordinates<java.lang.Double> collisionPoint)Return if the collisionPoint given is contain in the hit-box described by the topLeft point and the dimension. The hit-box is a rectangle, with a left-top point and width/height are determined by dimension. The points is contain in the rectangle if the condition are satisfied : -his X is contain between the minX and maxX of the rectangle, between coords.getX() and coords.getX() + dimension.getWidth() -his Y is contain between the minY and maxY of the rectangle, between coords.getY() and coords.getY() + dimension.getHeight()- Parameters:
topLeft- the top-left points of the rectangledimension- the dimension of the rectanglecollisionPoint- a point- Returns:
- if the collisionPoint is include in the rectangle described by the topLeft point and the dimension.
-
simplyCollide
Return if there is a collision between the 2 entity The type of calculation used to do that is simplest than the usual way to do that- Parameters:
entity1- an entityentity2- an entity- Returns:
- if there is a collision between the 2 entity, with a simple kind of calculation
-