@Override public boolean update(double timeDelta) { Vector2f moveDelta = new Vector2f(getVelocity()); moveDelta.scale((float) timeDelta); Vector2f.add(getPosition(), moveDelta, getPosition()); if (Math.abs(getPosition().x) > halfRangeX || Math.abs(getPosition().y) > halfRangeY) return true; return false; }
public static void truncate(Vector2f vector, float max) { float length = vector.length(); if (length == 0) return; float i = max / length; vector.scale(i < 1. ? 1.f : i); }