Damped spring physics + Newtonian projectile sim
Pure-math animation engine. Damped harmonic oscillators (Ryan-Juckett) for smooth scroll / overshoot, Newtonian projectile sim for arcs and particle effects. No terminal dependency.
composer require candycore/honey-bounce
use CandyCore\Bounce\{Spring, Projectile, Point, Vector};
$spring = new Spring(
deltaTime: Spring::fps(60),
angularFrequency: 6.0,
dampingRatio: 1.0, // critical
);
$pos = 0.0; $vel = 0.0; $target = 100.0;
for ($f = 0; $f < 60; $f++) {
[$pos, $vel] = $spring->update($pos, $vel, $target);
}
$ball = Projectile::new(
deltaTime: Spring::fps(60),
position: Point::zero(),
velocity: new Vector(5.0, -10.0),
acceleration: Projectile::gravity(),
);
for ($i = 0; $i < 60; $i++) {
$ball = $ball->update();
}
dampingRatio < 1 oscillates, = 1 critical (no overshoot, fastest), > 1 over-damped.Projectile::gravity() + terminalGravity() helpers.Spring::fps(60) returns 1/60 deltaTime. Pair with a 60Hz loop for smooth animation.$pos and $vel in, gets the next pair out.ext-pcntl, nothing. Drop into a job worker if you need physics in a non-TUI.VHS-recorded GIFs of every example shipped with the library. Regenerated automatically on every push that touches the source.