use of com.almasb.fxgl.core.math.Vec2 in project FXGL by AlmasB.
the class JBoxUtils method clamp.
public static final Vec2 clamp(final Vec2 a, final Vec2 low, final Vec2 high) {
final Vec2 min = new Vec2();
min.x = a.x < high.x ? a.x : high.x;
min.y = a.y < high.y ? a.y : high.y;
min.x = low.x > min.x ? low.x : min.x;
min.y = low.y > min.y ? low.y : min.y;
return min;
}
use of com.almasb.fxgl.core.math.Vec2 in project FXGL by AlmasB.
the class ChainShape method getChildEdge.
/**
* Get a child edge.
*/
public void getChildEdge(EdgeShape edge, int index) {
assert (0 <= index && index < m_count - 1);
edge.setRadius(getRadius());
final Vec2 v0 = m_vertices[index + 0];
final Vec2 v1 = m_vertices[index + 1];
edge.m_vertex1.x = v0.x;
edge.m_vertex1.y = v0.y;
edge.m_vertex2.x = v1.x;
edge.m_vertex2.y = v1.y;
if (index > 0) {
Vec2 v = m_vertices[index - 1];
edge.m_vertex0.x = v.x;
edge.m_vertex0.y = v.y;
edge.m_hasVertex0 = true;
} else {
edge.m_vertex0.x = m_prevVertex.x;
edge.m_vertex0.y = m_prevVertex.y;
edge.m_hasVertex0 = m_hasPrevVertex;
}
if (index < m_count - 2) {
Vec2 v = m_vertices[index + 2];
edge.m_vertex3.x = v.x;
edge.m_vertex3.y = v.y;
edge.m_hasVertex3 = true;
} else {
edge.m_vertex3.x = m_nextVertex.x;
edge.m_vertex3.y = m_nextVertex.y;
edge.m_hasVertex3 = m_hasNextVertex;
}
}
use of com.almasb.fxgl.core.math.Vec2 in project FXGL by AlmasB.
the class VarsSample method initGame.
@Override
protected void initGame() {
getGameState().<Vec2>addListener("vector", ((prev, now) -> System.out.println(prev + " " + now)));
System.out.println(getGameState().getInt("test"));
System.out.println(getGameState().<Vec2>getObject("vector").x);
System.out.println(getGameState().<Vec2>objectProperty("vector").get().y);
getGameState().setValue("vector", new Vec2(300, 300));
}
use of com.almasb.fxgl.core.math.Vec2 in project FXGL by AlmasB.
the class DefaultWorldPool method getVec2Array.
public final Vec2[] getVec2Array(int argLength) {
if (!avecs.containsKey(argLength)) {
Vec2[] ray = new Vec2[argLength];
for (int i = 0; i < argLength; i++) {
ray[i] = new Vec2();
}
avecs.put(argLength, ray);
}
assert (avecs.get(argLength).length == argLength) : "Array not built with correct length";
return avecs.get(argLength);
}
use of com.almasb.fxgl.core.math.Vec2 in project FXGL by AlmasB.
the class VarsSample method initGame.
@Override
protected void initGame() {
getWorldProperties().<Vec2>addListener("vector", (prev, now) -> System.out.println(prev + " " + now));
System.out.println(getd("testDouble"));
System.out.println(getb("testBoolean"));
Vec2 vector = geto("vector");
System.out.println(vector.x);
System.out.println(getWorldProperties().<Vec2>objectProperty("vector").get().y);
set("vector", new Vec2(300, 300));
}
Aggregations