private void predictCollisions(Ball sourceBall) { double dt = CollisionUtils.calcTimeToHitWall(sourceBall, WallType.HORIZONTAL); if (CollisionUtils.isCollisionConsistency(dt)) { queue.add(new WallCollisionEvent(timer.getTimestamp(dt), sourceBall, WallType.HORIZONTAL)); } dt = CollisionUtils.calcTimeToHitWall(sourceBall, WallType.VERTICAL); if (CollisionUtils.isCollisionConsistency(dt)) { queue.add(new WallCollisionEvent(timer.getTimestamp(dt), sourceBall, WallType.VERTICAL)); } for (Ball targetBall : objectContainer.getBalls()) { dt = CollisionUtils.calcTimeToHitBall(sourceBall, targetBall); if (CollisionUtils.isCollisionConsistency(dt)) { queue.add(new BallCollisionEvent(timer.getTimestamp(dt), sourceBall, targetBall)); } } }
private void moveBalls(double dt) { for (Ball ball : objectContainer.getBalls()) { ball.move(dt); } }
public void init() { for (Ball ball : objectContainer.getBalls()) { predictCollisions(ball); } }