@rpgjs/physic
Version:
A deterministic 2D top-down physics library for RPG, sandbox and MMO games
27 lines (26 loc) • 620 B
JavaScript
class LinearMove {
/**
* Creates a linear movement strategy.
*
* @param velocity - Velocity to apply (units per second)
* @param duration - Optional duration in seconds (undefined for infinite)
*/
constructor(velocity, duration) {
this.velocity = velocity;
this.duration = duration;
this.elapsed = 0;
}
update(body, dt) {
if (this.duration !== void 0) {
this.elapsed += dt;
}
body.setVelocity(this.velocity);
}
isFinished() {
return this.duration !== void 0 && this.elapsed >= this.duration;
}
}
export {
LinearMove
};
//# sourceMappingURL=index36.js.map