| name | move-and-time |
| description | Move things smoothly and schedule actions using the engine frame clock, the Timer helper, and easing. Use for movement, timers, cooldowns, spawn intervals, animation frames, or anything that should happen 'every N frames' or 'over N seconds'. |
Move and time things
Use the engine's frame clock to move things smoothly, repeat actions on a schedule, and ease motion.
When to use
Use for movement, timers, cooldowns, spawn intervals, animation frames, or anything that should happen "every N frames"
or "over N seconds".
Read-only clock (properties, no parentheses)
update() {
if (BT.ticks % 30 === 0) {
this.spawnEnemy();
}
this.x += this.speedPerSecond * BT.deltaSeconds;
}
BT.ticks, BT.timeSeconds, BT.deltaSeconds, BT.targetFPS – all getters.
BT.ticksReset() (method) – zero the tick counter, e.g. on restart.
Timer helper
import { Timer } from 'blit386';
this.fireTimer = new Timer(20);
if (this.fireTimer.fireIfElapsed(BT.ticks)) {
this.fire();
}
Easing for smooth motion
import { applyEasing } from 'blit386';
const t = (BT.ticks % 60) / 60;
const eased = applyEasing(t, 'ease-in-out');
this.y = Math.floor(100 + eased * 50);
Notes
- Do timing in
update(), not render().
- Round to whole numbers before drawing (
Math.floor) – rendering is integer-only.
Timer.fireIfElapsed() advances its own state, so call it once per frame.
See docs/basics.md.