Animate a sprite
Frames, timing, and not tying animation to frame rate.
Add sprite animation. My sprite sheet: <dimensions, frames per row, frame size>. - An animation is a named list of frame indices plus a duration per frame, driven by elapsed time — never by frame count. - Support looping and one-shot animations, with a callback when a one-shot finishes. - Switching animation resets to frame zero, unless I ask it not to. - Horizontal flip for facing direction, without a second sheet. Define the animations as data at the top so I can add one without touching the drawing code. Then show me how I'd drive it from state: idle when not moving, run when moving, jump when airborne.
Frame-count timing looks right on your machine and runs at double speed on a 120Hz display. Elapsed time is the only version that's correct everywhere.