step

fun step(dt: Duration)(source)

Advances the world by dt, in PhysicsConfig.substeps substeps. Step by the same fixed time every frame, such as a 60th of a second, for results that do not depend on the frame rate.

Throws

if dt is not more than zero or is infinite.

Samples

val world = PhysicsWorld()
val ball = world.particles.add(x = 0f, y = 0f)

// A second of 60 fixed steps; gravity pulls down, and y grows down.
repeat(60) { world.step(1.seconds / 60) }

assertPrints(world.stepCount, "60")
assertTrue(world.particles.yOf(ball) > 500f)
assertPrints(world.particles.xOf(ball), "0.0")